<template>
  <div class="order-buy">
    <div>
      <!--  会员服务购买 常俊海定制 start  -->
      <div class="memberpay-header" v-if="ischjDz">
        <p class="memberGrade-title">{{buyLists[0].title}}</p>
        <p class="memberGrade-price">
          <span>¥</span>
          <span>{{buyLists[0].price}}</span>
        </p>
      </div>
      <!--  会员服务购买 常俊海定制 end  -->
      <template v-if="resData.send_gift && resData.is_gift_address == 1 || !resData.send_gift">
      <div class="order-con" v-if="(resData.is_freight==0 || dingguagua_dz_is_freight) && (!resData.send_gift || resData.post_fee==0)">
        <!-- 配送方式 -->
        <mode-distribution
          ref="modeDistribution"
          :listShipping="list_shipping"
          :shippingType='formData.shipping_type'
          :buyLists="buyLists"
          :latitude="formData.latitude"
          :longitude="formData.longitude"
          :isKuajing="isKuajing"
          :selectLastLocation="formData.select_last_location"
          @getShippingType="getShippingType"
          @getSelfAddress="getSelfAddress"
          @getDateTime="getDateTime"
          :store_delivery="resData.store_delivery"
          ></mode-distribution>

        <!-- 地址管理 -->
        <address-admin  ref="addressAdmin"
                        :shippingType='formData.shipping_type'
                        :shippingTemp="resData.shipping_temp"
                        :addressArr="resData.address"
                        :takeTheirName="resData.take_their_name"
                        :storeHideMobile="resData.storeHideMobile || 1"
                        :tmpdata="selfAddressInfo"
                        :dingguagua_dz_is_freight="dingguagua_dz_is_freight"
                        @openSelfAddress="openSelfAddress"
                      >
        </address-admin>
        <div v-if="dingguagua_dz_is_freight" style="padding-left: 10px;padding-right: 10px;">
          选择学习地址说明：部分课程同时提供线上、线下教学服务， 请您选择便于线下学习的省、市、区/县地址；
        </div>
      </div>
      <!-- 定制 江西赣中旅 start -->
      <div class="order-con" v-else>
        <div v-if="user_info">
          <section class="item-block item-block2" v-if="is_jxgzl_dz==1">
            <div class="item-box">
              <span class="item-title"><span class="colorRed">*</span> 姓名</span>
              <div class="item-con">
                <input type="text" name="receiver_name_dz" placeholder="请填写收货人的姓名" v-model="formData.receiver_name_dz" class="ip">
              </div>
            </div>
            <div class="item-box">
              <span class="item-title"><span class="colorRed">*</span> 手机</span>
              <div class="item-con">
                <input type="tel" name="receiver_mobile_dz" placeholder="请填写收货人的手机号码" v-model="formData.receiver_mobile_dz" class="ip">
              </div>
            </div>
          </section>
          <!-- 虚拟商品打开开关,必须填写的信息 -->
          <section v-else-if="isVirtualGoods">
            <div class="item-block item-block2 purchase_infos">
              <div class="item-box">
                <span class="item-title"><span class="colorRed">*</span><span>姓名：</span></span>
                <section class="item-con">
                  <input class="item-input" type="text" name="id_cert_name" placeholder="请输入姓名" v-model="formData.virtual_username"/>
                </section>
              </div>
              <div class="item-box">
                <span class="item-title"><span class="colorRed">*</span><span>手机：</span></span>
                <section class="item-con">
                  <input class="item-input" type="text" name="id_cert_name" placeholder="请输入手机" v-model="formData.virtual_phone"/>
                </section>
              </div>
              <div class="text-tips">{{virtual_add_order_desc}}</div>
            </div>
          </section>
          <section class="item-block item-block2" v-else>
            <p class="item-li">姓名：<span class="name">{{user_info.name}}</span></p>
            <p class="item-li">手机：<span class="tel">{{user_info.mobile}}</span></p>
          </section>
        </div>
      </div>
      <!-- 定制 江西赣中旅 end -->
      </template>
      <!-- 门店服务奖地址选择 -->
      <store-serve-addr-dlg-cpt ref="store-serve-addr-dlg-cpt"
      :shipType='formData.shipping_type'
      :visible.sync="storeSveAddrDlg.visible"
      :latitude="formData.latitude"
      :longitude="formData.longitude"
      selectLastLocation=""
      @getSelfAddress="getStoreSelfAddress"
      ></store-serve-addr-dlg-cpt>

      <div class="item-block item-block2">
        <!-- 订购人 -->
        <div class="item-box" v-if="resData.is_buy_card==1 && resData.is_id_cert_name==1">
          <span class="item-title"><span class="colorRed">*</span><span >{{resData.id_cert_name}}</span></span>
          <section class="item-con">
            <input class="item-input" type="text" name="id_cert_name" :placeholder="'请输入'+resData.id_cert_name" v-model="formData.id_cert_name"/>
          </section>
        </div>
        <!-- 身份证号 -->
        <div class="item-box" v-if="resData.is_buy_card==1">
          <span class="item-title"><span class="colorRed">*</span><span id="card_alias">{{resData.card_alias}}</span></span>
          <section class="item-con">
            <input class="item-input" type="text" name="id_card" :placeholder="'请输入'+resData.card_alias+'号'" v-model="formData.id_card"/>
          </section>
        </div>
        <section class="card-tip" v-if="resData.need_idcard_desc">
          <i class="fl"></i>
          <span>{{resData.need_idcard_desc}}</span>
        </section>

        <div class="order-con" v-if="resData.id_pros_cons">
          <div class="item-box">
            <span class="item-title"><span class="colorRed">*</span>{{resData.card_positive_name?resData.card_positive_name:resData.card_alias+'正面'}}</span>
          </div>
          <div class="upload">
            <!-- TODO 小程序上传图片 -->
            <SmallUploadImg ref="smallUploadImg1" :isUploadSfz="isUploadSfz" :sfzBg="prosImg" :imageList="cardImgArr1" :maxLength="maxLength"></SmallUploadImg>

          </div>
        </div>
        <div class="order-con" v-if="resData.id_pros_cons&&!resData.id_pros_cons_one">
          <div class="item-box">
            <span class="item-title"><span class="colorRed">*</span>{{resData.card_alias}}反面</span>
          </div>
          <div class="upload">
            <!-- TODO 小程序上传图片 -->
            <SmallUploadImg ref="smallUploadImg2" :isUploadSfz="isUploadSfz" :sfzBg="consImg" :imageList="cardImgArr2" :maxLength="maxLength"></SmallUploadImg>
          </div>
        </div>
        <div class="order-con" v-if="!resData.id_pros_cons&&resData.custom_pic && resData.custom_pic_num>0">
          <div class="item-box">
            <span class="item-title custom-pic-title">
              <span class="colorRed flex-shrink">*</span>
              <div class="cunstom-text">
              请上传1-{{resData.custom_pic_num?resData.custom_pic_num+'张':''}}图片({{resData.custom_pic_msg?resData.custom_pic_msg:''}})
              </div>
            </span>
          </div>
          <!-- <van-uploader v-model="formData.custom_pic" icon="photo" multiple :max-count="Number(resData.custom_pic_num)"/> -->
          <!-- TODO 小程序上传图片 -->
          <SmallUploadImg ref="smallUploadImg3" :maxLength="Number(resData.custom_pic_num)"></SmallUploadImg>
        </div>

        <div class="item-box" v-if="resData.is_order_email==1">
          <span class="item-title"><span class="colorRed">*</span>邮箱</span>
          <section class="item-con">
            <input class="item-input" type="text" name="e_mail" placeholder="请输入邮箱" v-model="formData.e_mail"/>
          </section>
        </div>

        <div class="item-box" v-if="resData.is_self_mobile==1" v-show="isShowSelfMobile">
          <span class="item-title"><span class="colorRed">*</span>姓名</span>
          <section class="item-con">
            <input class="item-input" type="text" name="user_realname" placeholder="请输入姓名" v-model="formData.user_realname"/>
          </section>
        </div>

        <div class="item-box"  v-if="resData.is_self_mobile==1" v-show="isShowSelfMobile">
          <span class="item-title"><span class="colorRed">*</span>手机号码</span>
          <section class="item-con">
            <input class="item-input" type="text" name="user_mobile"  placeholder="请输入手机号码" v-model="formData.user_mobile"/>
          </section>
        </div>
      </div>

      <!-- 定制 医疗 处方信息 start  -->
      <div class="prescription-info-wrapper" @click="showPrescriptionInfo" v-if="prescription_drug">
        <div class="prescription-info " v-if="medical_patient_id">
          <div class="left success">
            <div class="title">已提交问诊信息</div>
            <div class="desc">医生会根据您的问诊信息为您提供处方服务。</div>
          </div>
          <div class="right">
            <span>查看</span>
            <svg-icon icon-class="icon_right" class="all-class-icon"></svg-icon>
          </div>
        </div>
        <div class="prescription-info" v-else>
          <div class="left warning">
            <div class="title">请添加用药人信息</div>
            <div class="desc">请认真填写线下初诊处方信息，确认使用过所购药片且无过敏等不良反应，当前病情稳定。</div>
          </div>
          <div class="right">
            <span>添加处方</span>
            <svg-icon icon-class="icon_right" class="all-class-icon"></svg-icon>
          </div>
        </div>
      </div>
      <!-- 定制 医疗 处方信息 end  -->

      <!-- 商品信息   ischjDz 判断常俊海定制 -->
      <goods-info :buyLists="buyLists"
                  :isPaypal="resData.is_paypal"
                  :isDzWm="isDzWm"
                  v-if="!ischjDz"
                  :isOpenKuajing="resData.is_open_kuajing"></goods-info>
      <!-- 优惠活动及运费等 -->
      <!-- 定制 赠品规格选择 start -->
      <section class="item-block item-block2" v-if="resData.specifications && resData.specifications.length>0">
        <div class="gift-list">
          <div class="title">赠品选择规格</div>
          <div class="gift-sku">
            <div class="small-title">品类：</div>
            <div class="gift-dz">
              <!-- <div class="click-gift-sku">{{list.name}}</div> -->
              <div :class="showCategory == list.name ?'click-gift-sku':''" v-for="list in resData.specifications" :key="list.id" @click="onShowItem(list)">{{list.name}}</div>
            </div>
          </div>
          <div class="gift-sku" v-if="firstDetails.length>0">
            <div class="small-title">规格 1：</div>
            <div class="gift-dz">
              <div :class="showFirst == list.name ?'click-gift-sku':''" v-for="list in firstDetails" :key="list.id" @click="onShowSkuFirst(list)">{{list.name}}</div>
            </div>
          </div>
          <div class="gift-sku" v-if="secondDetails.length>0">
            <div class="small-title">规格 2：</div>
            <div class="gift-dz">
              <div :class="showSecond == list.name ?'click-gift-sku':''" v-for="list in secondDetails" :key="list.id" @click="onShowSkuSecond(list.name)">{{list.name}}</div>
            </div>
          </div>
        </div>
      </section>
      <!-- 定制 赠品规格选择 end -->
      <section class="item-block item-block2">
        <!-- 预约时间 -->
        <!--  -->
        <div class="item-box" v-if="resData.is_store_reservation_service==1" @click="selectSubDate" v-show="isShowSubscribe"> <!--v-if="isShowSubscribe"-->
            <span class="item-title">预约时间</span>
            <div class="item-con">
              <span class="item-span">{{subscribeTime?subscribeTime:'请选择时间'}}</span>
              <span class="icon-right"></span>
            </div>
        </div>
        <!-- 入住时间 -->
        <section class="item-box" v-if="!resData.cart_buy&&order_extry.item_date">
          <span class="item-title">{{item_config.shopping_date_name}}</span>
          <section class="item-con">
            <span class="item-span">{{order_extry.item_date}}</span>
          </section>
        </section>
        <!-- 备注 -->
        <section class="item-box" v-if="!resData.cart_buy&&order_extry.item_memo">
          <span class="item-title">备注</span>
          <section class="item-con">
            <span class="item-span">{{order_extry.item_memo}}</span>
          </section>
        </section>
        <!-- 优惠券 -->
        <section class="item-box coupon-tips" v-if="coupon_lists && coupon_lists.length>0 && resData.user_can_use_coupon == 1"  @click="discountCoupon">
          <span class="item-title">{{resData.ftitle_coupon_name}}</span>
          <section class="item-con">
            <span class="item-span span-red" v-if="resData.coupon_num" style="font-weight: bold;">{{discountCouponValue(formData.user_coupon_id)}}</span>
            <span class="" v-if="formData.user_coupon_id"></span>
            <span class="icon-right"></span>
          </section>
        </section>

        <div v-if="coupon_lists && coupon_lists.length>0 && resData.user_can_use_coupon == 1">
          <div class="popTips" v-if="showPopTips && resData.max_coupon_amount && resData.max_coupon_amount.user_coupon_id">
            <div class="pop-tips-wrap">
              <span class="txt" @click="handleClickMaxCoupon">点击使用优惠最大的优惠券</span>
              <span class="icon" @click="showPopTips = false"><img src="https://img.wifenxiao.com/h5-wfx/images/order/icon_close.png" alt=""></span>
            </div>
          </div>
        </div>
        <!--定制：供应商优惠券-->
        <section class="item-box" v-if="coupon_lists_ZJHL_DZ && coupon_lists_ZJHL_DZ.length>0"  @click="dzDiscountCoupon">
          <span class="item-title">供应商优惠券</span>
          <section class="item-con">
            <span class="item-span span-red" v-if="resData.coupon_num_ZJHL_DZ">{{dzDiscountCouponValue(formData.user_sup_coupon_id)}}</span>
            <span class="icon-right"></span>
          </section>
        </section>
        <!-- 优惠码 -->
        <section class="item-box" v-if="resData.is_use_coupon_code==1" @click="discountCode">
          <span class="item-title">{{resData.coupon_code_alias}}</span>
          <section class="item-con">
            <span class="item-span span-red">{{couponCodePrice!=0?'-¥'+couponCodePrice:''}}</span>
            <span class="icon-right"></span>
          </section>
        </section>
        <!--定制：员工优惠码-->
        <section class="item-box" v-if="resData.staff_code_as_name==1 && resData.has_active != 1" @click="dzDiscountCode">
          <span class="item-title">{{resData.coupon_code_alias}}</span>
          <section class="item-con">
            <span class="item-span span-red">{{dzCouponCodePrice!=0?'-¥'+dzCouponCodePrice:''}}</span>
            <span class="icon-right"></span>
          </section>
        </section>
        <!-- end -->
        <section class="item-box" v-if="resData.is_repurchase">
          <span class="item-title">复购优惠</span>
          <section class="item-con">
            <span class="item-span">
              <i class="smallsize">{{mSymbol.name}}{{resData.coupon_repurchase_price}}</i>元
            </span>
          </section>
        </section>
        <!-- 满减优惠 -->
        <section class="item-box" v-if="resData.subtract_msg">
          <span class="item-title">活动优惠</span>
          <section  class="item-con">
            <span class="item-span span-def">{{resData.subtract_msg}}</span>
          </section>
        </section>
        <!-- 满件打折 -->
        <section v-if="used_promotion_type && used_promotion_type.length>0">
          <section class="item-box" v-for="(promotion,index) in used_promotion_type" :key='index'>
            <span class="item-title">{{promotion.promotion_name}}</span>
            <section  class="item-con">
              <span class="item-span span-def">{{promotion.promotion_memo}} 优惠{{promotion.total_promotion_amount}}元</span>
            </section>
          </section>
        </section>
        <!-- 首单立减 -->
        <section class="item-box" v-if="(resData.firstOrderRemission_price>0 || resData.firstOrderRemission_rate>0) && resData.is_fist_full_subtract_some_flag>0">
          <span class="item-title">首单立减</span>
          <section class="item-con">
            <span class="item-span span-def">新用户下单立减{{resData.firstOrderRemission_price > 0? resData.firstOrderRemission_price+'元':resData.firstOrderRemission_rate+'%'}}</span>
          </section>
        </section>
        <!-- 多买优惠 -->
        <section class="item-box" @click="showBmdPop" v-if="resData.desc_bmd_buy_list">
          <span class="item-title">多买优惠</span>
          <section class="item-con">
            <span class="item-span">{{resData.desc_bmd_buy_list.total_discount_money_desc}}</span>
            <span class="icon-right"></span>
          </section>
        </section>
        <!-- 配送运费 -->
        <section class="item-box" v-if="resData.is_freight==0 && resData.scanCode !=1 && !is_dhs_virtual">
          <span class="item-title">配送运费</span>
          <section class="item-con">
            <span class="item-span span-def" v-if="resData.freight_payer4 == 1">到付</span>
            <span v-if="resData.freight_payer4 !=1&&resData.full_mail_show" class="item-span span-def">({{resData.full_mail_show}})</span>
            <span v-if="resData.freight_payer4 !=1" class="item-span span-red"><i class="smallsize">{{mSymbol.name}}</i>{{postFee}}{{formData.is_freight_collect==1?'（到付）':''}}</span>
          </section>
        </section>
        <!-- 定制番茄 仓库结算 可赚 start -->
        <section class="item-box" v-if="is_dz_fq">
          <span class="item-title">可赚</span>
          <section class="item-con">
            <span class="item-span span-red">¥ {{resData.pre_commission}}</span>
          </section>
        </section>

        <!-- 定制番茄 仓库结算 可赚 end -->
        <!-- 欧普定制 -->
        <div class="msettlement_goods_con" v-if="is_dz_op ==0 && resData.dz_full_mail_money_msg">
          <section class="txtTip clearfix">
            <span>{{resData.dz_full_mail_money_msg}}</span>
          </section>
        </div>

        <section class="item-box" v-if="resData.is_allow_freight_collect==1" v-show="isShowFreightCollect">
          <span class="item-title">运费到付</span>
          <section class="item-con">
            <van-switch v-model="formData.is_freight_collect"
                        class="item-switch"
                        active-color="#EB040B"
                        inactive-color="#F2F2F2"
                        active-value="1"
                        inactive-value="0"
                        size="15px"/>
          </section>
        </section>

        <!-- 后台开启并设置了运费险，且不是订货商发货 -->
        <section class="item-box freight_insurance_switch" v-if="resData.is_freight_insurance!=0 && resData.freight_insurance && !resData.is_dhs_send"
                  v-show="isShowFreightInsurance">
          <span class="item-title">{{resData.freight_insurance_name?resData.freight_insurance_name:'运费险'}}
            <i class="smallsize">{{mSymbol.name}}<span>{{resData.freight_insurance}}</span></i>
          </span>
          <section class="item-con">
            <van-switch v-model="formData.is_freight_insurance"
                        class="item-switch"
                        active-color="#EB040B"
                        inactive-color="#F2F2F2"
                        active-value="1"
                        inactive-value="0"
                        size="15px"/>
          </section>
        </section>
        <section  class="txtTip"
                  v-show="formData.is_freight_insurance"
                  v-if="resData.is_freight_insurance!=0 && resData.freight_insurance && !resData.is_dhs_send &&resData.freight_insurance_desc">
            <i class="fl"></i>
            <span>{{resData.freight_insurance_desc}}</span>
        </section>
        <section class="item-box" v-if="resData.tax_fee !=0 || resData.tax_fee !='0.00'">
          <span class="item-title">{{resData.taxes_alias}}</span>
          <section class="item-con">
            <span class="item-span span-red">{{mSymbol.name}}{{resData.tax_fee}}</span>
          </section>
        </section>
        <!--传值 运费 -->
        <section class="item-box" v-if="!ischjDz">
          <span class="item-title"><span class="colorRed" v-if="resData.is_buyer_message==1">*</span>{{resData.buyer_message}}</span>
          <section class="item-con">
            <input class="item-input" name="message" v-model="formData.message" :placeholder="resData.buyer_message_hints"/>
          </section>
        </section>
        <!-- 开发票 -->
        <section class="item-box"
                v-if="resData.is_buy_invoice==1 && (resData.paper_invoice_enable==1 || resData.vat_invoice_enable==1 || resData.electronic_invoice_enable==1)"
                @click="showBill">
          <span class="item-title">开具发票</span>
          <section  class="item-con">
            <span class="item-span span-def">{{invoiceInfo}}</span>
            <span class="icon-right"></span>
          </section>
        </section>
        <!-- 是否享受门店服务 -->
        <section class="item-box"
                v-if="is_store_serve_choose==1"
                @click="selectStoreServe">
          <span class="item-title">选择服务门店</span>
          <section  class="item-con">
            <span class="item-span span-def">{{selfStoreAddressInfo.shop_name}}</span>
            <span class="icon-right"></span>
          </section>
        </section>
        <!--定制 薇曼  start  -->
        <!-- <if condition="$buy_vo['dz_price']">
            <input type="hidden" name="dz_wm_total" value="{$dz_wm_total}">
            <input type="hidden" name="dz_wm_totalPrice" value="{$payment}" data-before="{$before_payment}">
        </if> -->
        <!--定制 薇曼  end  -->
        <!-- 金额计算 -->
        <section class="money-box" v-show="!ischjDz">
          <!-- 所需积分 -->
          <p class="msettlement_intle" v-if="resData.buy_need_points">所需{{resData.dz_cash_point ? resData.dz_cash_point_alias : resData.point_name}}：<span class="menoy-num">{{resData.buy_need_points}}</span></p>
          <!-- 所需虚拟币 -->
          <p class="msettlement_intle" v-if="resData.buy_need_virtual_currency">所需{{resData.virtual_currency_title}}：<span class="menoy-num">{{resData.buy_need_virtual_currency}}</span></p>
          <!-- 赠送积分 --><!-- 十人团定制不显示赠送积分 -->
          <p class="msettlement_intle" v-if="sendPoint > 0 && !istendz && !is_show_dhs_virtual_point && resData.is_point_trader_show == 1 && !resData.is_dhs_send">赠送{{resData.point_name}}：<span class="menoy-num">{{sendPoint}}</span></p>
          <!-- 税费 -->
          <p class="msettlement_int" v-if="formData.is_invoice_type!=1">发票税费：<span class="menoy-num">{{mSymbol.name}}{{taxPrice}}</span></p>
          <!-- 预售需支付 -->
          <p class="msettlement_intle" v-if="resData.is_presale">需支付：<span class="menoy-num" v-html="scaleGoodsPriceFn(resData.deposit_payment)"></span></p>
          <!--总计-->
          <p class="msettlement_intle">
            <span>总计：</span>
            <span class="menoy-num group-money-num" v-if="isGroup==1" v-html="scaleGoodsPriceFn(reCountPrice)"></span>
            <span class="menoy-num" v-else v-html="scaleGoodsPriceFn(reCountPrice*1+bmd_goods_all_price*1)"></span>
            <span class="dollar-price" v-if="resData.is_paypal==1&&resData.dollar_payment>0">&dollar;{{resData.dollar_payment}}</span>
            <span v-if="resData.package_active_diff_price == 1" style="color:#F30C23;">（打包一口价）</span>
            <span v-if="isGroupShopping && isGroupShopping.tuan_no_pay ==1 && isGroupShopping.tuanOrderId == 0" style="color:#F30C23;">(团长免单)</span>
          </p>
        </section>
      </section>

      <!-- 订单备注 -->
      <div class="item-block item-block2 purchase_infos" v-if="resData.is_purchase_notes == 1">
        <div class="item-box" v-for="(item,ind) in purchaseInfoData" :key="ind">
          <span class="item-title"><span class="colorRed" v-if="item.checked == 1">*</span><span >{{item.key_value}}</span></span>
          <section class="item-con">
            <input class="item-input" type="text" name="id_cert_name" placeholder="请输入" v-model="item.purchase_value"/>
          </section>
        </div>
      </div>
      <!-- 订单备注 -->

      <!-- 积分，虚拟币抵用 -->
      <section class="item-block item-block2" v-if="!isKuajing && !ischjDz">
        <!-- 积分抵用 -->
        <section class="item-box" :class="resData.dz_cash_point? 'cashPoint': ''" v-if="resData.is_point_cash == 1 && resData.user_can_use_point == 1 && (isItemPointCashPercent && old_total > 0 || !isItemPointCashPercent)">
          <span
            v-if="isItemPointCashPercent && buyLists.length > 1"
            class="item-title">
              可用{{ Number(user_points_cj) > Number(old_total) ? Math.ceil(old_total * 100 / point_cash_cj) : user_points_cj }}{{ resData.dz_cash_point ? resData.dz_cash_point_alias : resData.point_name }}抵用
            <i class="smallsize">{{ mSymbol.name }}<span>{{ Number(point_payment_cj) > Number(old_total) ? old_total : point_payment_cj}}</span></i>
          </span>
          <span v-else class="item-title">可用{{formData.user_points}}{{ resData.dz_cash_point? resData.dz_cash_point_alias:resData.point_name}}抵用
            <i class="smallsize">{{mSymbol.name}}<span>{{point_cash_cache}}</span></i>
          </span>
          <section class="item-con">
            <van-switch v-model="is_point_payment"
                        class="item-switch"
                        active-color="#EB040B"
                        inactive-color="#F2F2F2"
                        size="15px"/>
          </section>
        </section>
        <p class="exchangeFee" v-if="resData.dz_cash_point && resData.is_point_cash == 1 && resData.user_can_use_point == 1">额外收取{{resData.dz_cash_point_deduct_fee_percent? Math.ceil(formData.user_points * (resData.dz_cash_point_deduct_fee_percent / 100)) : resData.dz_cash_point_deduct_fee}}个{{resData.dz_cash_point_alias? resData.dz_cash_point_alias: resData.point_name}}手续费</p>
        <!-- 虚拟币抵用 -->
        <section class="item-box" v-if="resData.is_virtual_currency && resData.is_virtual_currency_cash">
          <span class="item-title">可用{{formData.user_virtual}}{{resData.virtual_currency_title}}抵用
            <i class="smallsize">&yen;<span>{{virtual_cash_cache}}</span></i>
          </span>
          <section class="item-con">
            <van-switch v-model="is_virtual_payment"
                        class="item-switch"
                        active-color="#EB040B"
                        inactive-color="#F2F2F2"
                        size="15px"/>
          </section>
        </section>

      </section>
      <!-- 充值优惠 -->
      <div class="item-block charge_adv" v-if="isShowchargeAdv" @click="JumpName('rechargeList')">
          <div class="num">
            充<span class="num_font">{{chargeAmount}}</span>
            送<span class="num_back">{{chargeNun}}</span>
            <span>多充多送</span>
          </div>
      </div>
      <!--定制 薇曼  start  -->
      <section class="item-block dz_wm" v-if="resData.dz_wm_total">温馨提示：不可混合支付．使用余额支付，需支付&yen;{{formData.dz_balance}}；使用线上支付，需支付&yen;{{formData.dz_online}}。
        <input type="hidden" name="dz_wm_type" value="">
      </section>
      <!--定制 薇曼  end  -->
      <!-- 余额，预存款  虚拟库存 ，门店库存;   is_need_consultation处方药问诊不选择支付方式 -->
      <div class="item-block item-block2" v-if="resData.is_need_consultation != 1">
        <div class="item-box" v-if="user_balance !=0 && resData.is_item_support_balance_pay && resData.is_open_balance_pay==1 && tlyeShow" v-show="isShowPayment">
          <van-checkbox class="item-title" @change="handleChangeBalance" :disabled="hfShowNoPay" v-model="money_type" shape="square" icon-size="14px">
            使用{{resData.balance_alias}}
              <i>({{resData.balance_alias}}：<span class="smallsize" :class="hfShowNoPay ? 'hfSmall' : 'smallsize'">{{mSymbol.name}}<b>{{user_balance}}</b></span>)</i>
            <template #icon="props">
              <img class="img-icon" :src="props.checked ? activeIcon : inactiveIcon" />
            </template>
          </van-checkbox>
        </div>
        <div v-if="!isKuajing && !ischjDz">
          <div class="item-box" v-if="resData.is_advance_deposit_pay == 1 && resData.is_dhs_allow_deposit ==1 && resData.is_check_dhs==1 && resData.dhs_deposit && resData.dhs_deposit !=0 && (resData.yck_dz_open == 0 || (resData.yck_dz_open == 1 && resData.is_dz_can_use_deposit==1))">
            <van-checkbox class="item-title" v-model="money_type2" shape="square" icon-size="14px">
              使用{{resData.deposit_alias}}
              <i>(订货商{{resData.deposit_alias}}：<span class="smallsize">{{mSymbol.name}}<b>{{resData.dhs_deposit}}</b></span>)</i>
              <template #icon="props">
                <img class="img-icon" :src="props.checked ? activeIcon : inactiveIcon" />
              </template>
            </van-checkbox>
          </div>
          <div class="item-box" v-if="resData.is_dhs_delivery_open == 1 && resData.is_check_dhs == 1">
            <van-checkbox class="item-title" :disabled="is_buy_dhs_entity_disabled" @change="handleChangeEntity" v-model="is_buy_dhs_entity" shape="square" icon-size="14px">
              购买实体库存
              <template #icon="props">
                <img class="img-icon" :src="props.checked ? activeIcon : inactiveIcon" />
              </template>
            </van-checkbox>
          </div>
          <!-- 云仓礼包商品订单不支持购买虚拟库存  is_yuncang_gift 0 非云仓礼包 1 云仓礼包-->
          <div class="item-box" v-if="resData.is_check_dhs==1&& !resData.is_dhs_send&& !resData.item_cycle_buy_id&& resData.is_dhs_virual_stock==1&& !resData.has_bursting && !resData.scanCode && resData.is_yuncang_gift == 0 && !ischjDz">
            <van-checkbox class="item-title" :disabled="is_dhs_virtual_disabled" @change="handleChangeVirtual"  v-model="is_dhs_virtual" shape="square" icon-size="14px">
              <!-- 购买虚拟库存 -->
              {{dhs_virtual_txt}}
              <template #icon="props">
                <img class="img-icon" :src="props.checked ? activeIcon : inactiveIcon" />
              </template>
            </van-checkbox>
          </div>

          <div class="item-box" v-if="resData.is_store && resData.is_store_buy_stock && !resData.is_dhs_send &&  !resData.item_cycle_buy_id &&  !resData.has_bursting && !resData.scanCode">
            <van-checkbox class="item-title"  v-model="is_store_stock" shape="square" icon-size="14px">
              购买门店库存
              <template #icon="props">
                <img class="img-icon" :src="props.checked ? activeIcon : inactiveIcon" />
              </template>
            </van-checkbox>
          </div>
        </div>
      </div>
      <!-- 其他支付方式; is_need_consultation处方药问诊不选择支付方式 -->
      <div class="item-block item-block2" v-show="isShowOtherPayment && resData.is_need_consultation != 1">
        <pay-ment ref="payments"
            @globalAlipay="globalAlipay"
            :isKuajing="!isKuajing"
            :itemIds="itemIds"
            :isBuy="true"
            :itemIsCod="itemIsCod"
            :isTlfzPay="true"
            :isJhPay="true"
            @paymentData='paymentData'
            :istl= "istl"
            :isHffzPay="true"
            :tlInfobz = 'tlInfobz'
            v-model="paymentWay"></pay-ment>
        <div class="paymethodnote" v-if=" shop_info && shop_info.qipay_open && !resData.tuan_leader_needpay">
          <span>温馨提示：</span>支付宝支付{{shop_info.title}}已使用启博微付代收款业务，该笔订单将支付给启博科技，请放心支付！<br>
        </div>
      </div>
      <!-- 购买协议 -->
      <div v-if="resData.is_item_agreement==1">
        <van-dialog
          v-model="isShowPurchaseAgreement"
          :title="purchase_agreement_name"
          close-on-click-overlay
          @confirm="closePurchaseAgreement"
          class="common-confirm"
        >
          <div class="purchase_agreement_container">
              <div class="purchase_agreement_box">
                  <div class="purchase_agreement_content" v-html="purchase_agreement_content">
                  </div>
              </div>
          </div>
        </van-dialog>
        <van-checkbox-group class="purchase_agreement purchase_agreement_noflex" v-model="agreementId">
          <van-checkbox v-for="(item,ind) in resData.item_agreement_lists" :key="ind" class="purchase_agreement-checkbox" :name="item.item_id" checked-color="#F30C23" shape="square" icon-size="14px"><span class="tips">{{item.purchase_agreement_tips}}</span><span class="title" @click.stop="showPurchaseAgreement(item.item_id)">《{{item.purchase_agreement_name}}》</span></van-checkbox>
        </van-checkbox-group>
      </div>
      <div v-if="resData.is_item_agreement!=1 && resData.is_open_purchase_agreement==1">
        <!--购买协议弹窗-->
        <van-dialog
          v-model="isShowPurchaseAgreement"
          :title="resData.purchase_agreement_name"
          close-on-click-overlay
          @confirm="closePurchaseAgreement"
          class="common-confirm"
        >
          <div class="purchase_agreement_container">
              <div class="purchase_agreement_box">
                  <div class="purchase_agreement_content" v-html="resData.purchase_agreement_content">
                  </div>
              </div>
          </div>
        </van-dialog>
        <div class="purchase_agreement">
          <van-checkbox class="purchase_agreement-checkbox" v-model="is_agree_purchase_agreement" checked-color="#F30C23" shape="square" icon-size="14px"></van-checkbox>
          {{resData.purchase_agreement_tips}}<span class="title" @click="showPurchaseAgreement">《{{resData.purchase_agreement_name}}》</span>
        </div>
      </div>

      <!-- 支付按钮 -->
      <section class="msettlement_sub" v-if="allowGetLocation">
        <div class="bmd-tips" v-if="is_bmd_discount==1 && is_display_bmd_desc==1"><i></i><span>多买优惠商品不支持优惠叠加</span></div>

        <template v-else-if="isDingWei && !isOrder">
          <div class="btn-addorder red-gra-btn" v-if="!isSubmit" :data-ispresale="resData.is_presale?true:false" @click="openPayPop">提交订单</div>
        </template>
        <template v-else-if="!isDingWei">
          <div class="btn-addorder red-gra-btn" @click="onGetLocation">提交订单</div>
        </template>
        <template v-else-if="isOrder">
          <div class="btn-addorder red-gra-btn btn-disable">提交订单</div>
        </template>

        <div class="btn-addorder red-gra-btn btn-disable" v-if="isSubmit" :data-ispresale="resData.is_presale?true:false">提交中</div>

      </section>
    </div>
    <!-- 各种弹窗 -->
    <!-- 预约时间弹层 -->
    <subscribe ref="subscribe" @dateTime="dateTime"></subscribe>
    <!-- 优惠券弹层 -->
    <discount-coupon
        ref="discountCoupon"
        :userCouponId="formData.user_coupon_id?formData.user_coupon_id:'-1'"
        :couponLists="coupon_lists"></discount-coupon>
    <!-- 供应商优惠券弹层 -->
    <dz-discount-coupon
        ref="dzDiscountCoupon"
        :userCouponId="formData.user_sup_coupon_id?formData.user_sup_coupon_id:'-1'"
        :couponLists="coupon_lists_ZJHL_DZ"></dz-discount-coupon>
    <!--  优惠码弹层 -->
    <discount-code
        ref="discountCode"
        :title="resData.coupon_code_alias"
        :is_wx="resData.is_wx"
        :itemIds="itemIds"
        :payment="formData.getPost"
        :current_price="current_price"
        :num="num"
        ></discount-code>
    <!--  定制：优惠码弹层 -->
    <discount-code
        ref="dzDiscountCode"
        :title="resData.staff_code_as_name"
        :itemIds="itemIds"
        :payment="formData.getPost"
        :current_price="current_price"
        :num="num"></discount-code>

    <!--  多买优惠弹层 -->
    <bmd-pop
        ref="bmdPop"
        v-if="resData.desc_bmd_buy_list"
        :bmdList="resData.desc_bmd_buy_list.discount_desc"
        :bmdTotal="resData.desc_bmd_buy_list.total_discount_money"
        ></bmd-pop>

    <!-- 开发票弹层 -->
    <bill ref="bill"
          :resData="resData"></bill>
    <!-- 支付密码弹窗 -->
    <pay-password :showPwd="showPwd" @closePwd="closePwd" @payPwdCallback="payPwdCallback"></pay-password>
    <!-- 正在支付中 -->
    <div class="paypopnote" v-show="isSubmit"><span>正在提交中……</span></div>
    <!-- TODO 小程序定位修改 -->
    <!-- <a-map @getLatLng="onGetLatLng" /> -->
    <div>
      <!--限购商品弹窗-->
      <van-dialog
        v-model="isShowurPchasingTip"
        class="pchasingTipConfirm"
        title=""
        theme= "round-button"
        width="290"
        :show-confirm-button="false"
        close-on-click-overlay
        close-on-popstate
      >
        <div class="pchasing_tip_container" :style="{padding: purchasingPrompt.content.modulePadding + 'px 0'}">
          <div class="purchase_tip_box">
            <div class="purchase_tip_content" v-html="purchasingPrompt.content.fulltext"></div>
          </div>
        </div>
      </van-dialog>
    </div>
    <div>
      <send-code-payment ref="sendCodePayment"  />
      <tlInfo ref="tlInfo" @tlSubmit="tlSubmit"></tlInfo>
    </div>
    <!-- 定制 医疗 处方单信息 start -->
    <prescriptionInfo
      :height="heightCfy"
      :position="position"
      :type="type"
      :visible="show_prescriptionInfo"
      :medicalPatientId="medical_patient_id"
      :medicalPatientItemId="medical_patient_item_id"
      @closeClick="closeClick"
      @saveClick="prescriptionInfoSaveClick"
    />
    <!-- 定制 医疗 处方单信息 end -->
  </div>
</template>

<script>
import Vue from 'vue'
import small from '@/smallapp/small'
import { isWeixinCient } from '@/utils/validate'
import { scaleGoodsPrice } from '@/utils/index.js'
import { openPage } from '@/utils/utils.js'
import { uploadImgs } from '@/api/community/article'
import Store from '@/utils/store'
import smllpay from '@/smallapp/smallpay'
import { medicineUrl } from '@/api/public/index.js'
import { getOrderBuyData, getGroupOrderBuyData, addOrder, GroupShoppingOrder, idCert, lastRuleByPayment, getPostFee, getSupplierPostFee, getLimitBuyPage } from '@/api/order/order.js'
import StoreServeAddrDlgCpt from './components/store-serve-addr-dlg'
import popup from '@/components/popup'
import PayPassword from '@/components/PayPassword/index'
import payMent from '@/components/Payment'
import addressAdmin from './components/addressAdmin/index.vue'
import modeDistribution from './components/modeDistribution/index.vue'
import goodsInfo from './components/goodsInfo/index.vue'
import subscribe from './components/subscribe/index.vue'
import discountCoupon from './components/discountCoupon/index.vue'
import dzDiscountCoupon from './components/dzDiscountCoupon/index.vue'
import discountCode from './components/discountCode/index.vue'
import dzDiscountCode from './components/dzDiscountCode/index.vue'
import bmdPop from './components/bmdPop/index.vue'
import aMap from '@/views/shop/storeList/components/amap'
import bill from './components/bill/index.vue'
import { Checkbox, CheckboxGroup, Switch, Uploader, Icon, Toast, Dialog } from 'vant'
import UploadImg from '@/components/UploadImg'
import SmallUploadImg from '@/components/SmallUploadImg'
import { GetWxTemplateId, PostAddWxTemplateId } from '@/api/small/common'
import sendCodePayment from './components/sendCodePayment/index'
import { mapGetters } from 'vuex'
import tlInfo from './components/tlInfo/index'
import prescriptionInfo from '@/views/dzWeb/dzPrescriptionDrug/prescriptionInfo'
Vue.use(Checkbox).use(CheckboxGroup)
Vue.use(Toast)
Vue.use(Dialog)
Vue.use(Switch).use(Uploader).use(Icon)
export default Vue.extend({
  components: {
    StoreServeAddrDlgCpt,
    modeDistribution,
    addressAdmin,
    goodsInfo,
    payMent,
    subscribe,
    discountCoupon,
    dzDiscountCoupon,
    discountCode,
    dzDiscountCode,
    bmdPop,
    bill,
    popup,
    PayPassword,
    UploadImg,
    SmallUploadImg,
    aMap,
    sendCodePayment,
    tlInfo,
    prescriptionInfo
  },
  data() {
    return {
      isGroup: 0, // 是否团购结算
      showPopTips: true,
      maxLength: 1, // TODO 上传身份证正反面的图片张数
      isUploadSfz: true, // 是否是上传身份证
      pointDefault: {}, // 存储积分抵现的默认数据
      getPostFeeflag: false,
      activeIcon: 'https://img.wifenxiao.com/h5-wfx/images/check_icon.png',
      inactiveIcon: 'https://img.wifenxiao.com/h5-wfx/images/uncheck__icon.png',
      paymentWay: '',
      is_wx_pay_h5: '0',
      isShowFreightCollect: true, // 是否显示运到付
      isShowPurchaseAgreement: false, // 是否显示全球
      idCard1: 'https://img.wifenxiao.com/h5-wfx/images/order/id_card1.png',
      idCard2: 'https://img.wifenxiao.com/h5-wfx/images/order/id_card2.png',
      subscribeTime: '',
      isShowSubscribe: false, // 是否显示预约时间，通过配送方式判断
      resData: {},
      user_info: {},
      is_jxgzl_dz: 0,
      is_dz_op: 0,
      self_user_info: {},
      order_extry: {},
      item_config: {},
      used_promotion_type: [],
      full_used_promotion_type: [],
      isGroupShopping: null,
      invoiceInfo: '不开发票',
      point_cash_cache: 0, // 积分抵用金额
      virtual_cash_cache: 0, // 虚拟币抵用金额
      buyLists: [], // 商品数组
      itemIds: [], // 商品id数组
      sku_id: [],
      sku_name: [],
      current_price: [],
      is_first_gift: [],
      num: [],
      active: [],
      buy_gift_type: [],
      dollar_price: [],
      sup_post_fee: [],
      new_supplier_id: [],
      supplier_ids: [],
      money_type: false, //  选用余额
      money_type2: false, // 选用预存款
      // 用于计算
      user_balance: 0, // 余额
      totalPrice: 0.00, // 商品总价
      is_bmd_discount: 0, // 多买优惠商品不支持优惠叠加,1为不参与
      is_display_bmd_desc: 0, // 是否显示‘多买优惠商品不支持优惠叠加’
      not_bmd_goods_all_price: 0.00, // 非多买优惠商品总价
      bmd_goods_all_price: 0.00, // 多买优惠商品价格
      eddprice: 0.00, // 最后需要支付的价格
      postFee: 0.00, // 运费
      couponPrice: 0, // 优惠券价格
      couponSupPrice: 0, // 供应商优惠券价格
      couponCodePrice: 0, // 优惠码价格
      dzCouponCodePrice: 0, // 定制优惠码价格
      taxPrice: 0, // 税费
      sendPoint: 0, // 赠送积分
      consumPoints: 0,
      consumPrices: 0,
      subArr: [],
      selfAddressInfo: {}, // 自提信息
      address_name: '',
      isShowFreightInsurance: true,
      isShowSelfMobile: false,
      showPwd: false, // 支付密码弹框是否显示
      isShowPayment: true,
      isShowOtherPayment: true,
      shop_info: {},
      isShowchargeAdv: false,
      chargeAmount: 0,
      chargeNun: 0,
      isKuajing: false, // 是不是跨境商品
      list_shipping: {},
      isDzWm: false,
      is_dxpp_dz: 0, // 大熊品牌定制
      coupon_lists: [],
      coupon_lists_ZJHL_DZ: [],
      is_free_logistics: false,
      isSubmit: false,
      isOrder: false,
      checkClick: false,
      is_point_payment: false,
      is_virtual_payment: false,
      is_dhs_virtual: false,
      is_buy_dhs_entity: false, // 是否默认勾选实体库存
      is_store_stock: false,
      is_agree_purchase_agreement: false,
      is_store_serve_choose: '',
      selfStoreAddressInfo: '',
      storeSveAddrDlg: {
        visible: false
      },

      formData: {
        'is_dhs_send': false,
        'id_cert_name': '',
        'id_card': '',
        'e_mail': '',
        'is_freight_collect': 0,
        'is_freight_insurance': 0,
        'global_alipay_currency': '',
        'hantepay': '',
        'allinpay': '',
        'newyeepay': '',
        'shipping_type': '',
        'latitude': undefined,
        'longitude': undefined,
        'money_type': '',
        'user_coupon_id': '',
        'user_sup_coupon_id': '',
        'max_coupon_value': '',
        'allow_coupon_items': '',
        'type': '',
        'id_pros': '',
        'id_cons': '',
        'custom_pic': [],
        'address_id': '',
        // 已选地址有没有经纬度
        'hasLatLng': false,
        'self_address_id': '',
        'user_realname': '',
        'user_mobile': '',
        'receiver_name_dz': '',
        'receiver_mobile_dz': '',
        'is_invoice_type': 1,
        'invoice_type': '',
        'invoice_no': '',
        'mail': '',
        'invoice_header': '',
        'company_address': '',
        'company_phone': '',
        'open_bank': '',
        'bank_account': '',
        'coupon_code': '',
        'coupon_code_price': '',
        'coupon_code_name': '',
        'message': '',
        'dz_balance': 0, // 薇曼定制价格
        'dz_online': 0,
        'serve_address_id': '',
        'is_store_serve': '',
        'virtual_username': '',
        'virtual_phone': '',
        'list_shipping_id': 0
      },
      is_yck_dz: 0, // 奇异国预存款定制
      dhs_virtual_txt: '购买虚拟库存',
      showAddress: true,
      // 单个商品允许设置购买协议-选中购买协议
      agreementId: [],
      is_show_dhs_virtual_point: false, // 勾选虚拟库存隐藏赠送积分
      purchase_agreement_name: '',
      purchase_agreement_content: '',
      // 虚拟库存设置
      isShowVirualStock: false,
      // 单个商品设置货到付款
      itemIsCod: 0,
      ltnsStatus: false,
      paymentDataList: {},
      // 限购展示
      isShowurPchasingTip: false,
      purchasingPrompt: {
        content: {},
        goto_time: 0
      },
      // 备注信息提交数据
      purchaseInfoData: [],
      memberitemId: '', // 常俊海定制 购买会员id
      istendz: 0, // 十人团定制
      ischjDz: false, // 常俊海定制状态
      is_buy_dhs_entity_disabled: false,
      is_dhs_virtual_disabled: false,
      dz_package_item_id: '', // 杭州得炫定制
      is_hzdx_dhs_dz: 0,
      is_dz_fq: 0, // 番茄定制仓库结算
      istl: false,
      tlyeShow: true,
      tlInfobz: {
        is_tlfz: 0,
        is_tlfz_deposit: 0,
        is_ye: 0
      },
      // 医疗定制 start
      prescription_drug: false, //  是否包含处方药
      show_prescriptionInfo: false,
      medical_patient_item_id: 0, // 处方药id
      medical_patient_id: 0, // 用药人id
      // 医疗定制 end
      cardImgArr1: [],
      cardImgArr2: [],
      is_jh_item_dz: 0,
      is_use_coupons: false, // 优惠券使用是否有变动
      is_use_integral: false, // 积分使用是否有变动
      is_use_virtual_currency: false, // 虚拟币使用是否有变动
      is_star_chain_item_dz: 0, // 星链供应链定制
      firstDetails: [],
      secondDetails: [],
      showCategory: '',
      showFirst: '',
      showSecond: '',
      isDingWei: true,
      dingguagua_dz_is_freight: 0, // 顶呱呱定制-虚拟物品要求显示地址
      remark: -1,
      order_id: '',
      hfAppId: '',
      allowGetLocation: true,
      isVirtualGoods: false,
      virtual_add_order_desc: '',
      hfShowNoPay: false,
      is_dataset_json: 0, // dataset 是否以json格式提交
      heightCfy: '100%',
      position: 'right',
      type: '',
      point_calculation_rule: 0, // 0 向下取整 1向上取整 2四舍五入
      isItemPointCashPercent: 0, // 是否开启积分抵现走单百分比
      user_points_cj: 0,
      point_payment_cj: 0,
      point_cash_cj: 0,
      old_total: 0
    }
  },
  watch: {
    'money_type'(val) {
      if (val) {
        this.money_type2 = false
        this.formData.money_type = 2
        // 薇曼定制
        if (this.resData.dz_wm_total && this.user_balance < this.formData.dz_balance) {
          this.money_type = false
          this.$Error('余额不足')
        }
        this.paymentWay = 'cancel'
      }

      if (!this.money_type2 && !val) {
        this.formData.money_type = ''
      }
    },
    'money_type2'(val) {
      if (val) {
        this.money_type = false
        this.formData.money_type = 3
        // 薇曼定制
        if (this.resData.dz_wm_total && this.resData.dhs_deposit < this.formData.dz_balance) {
          this.money_type2 = false
          this.$Error('预存款不足')
        }
      }
      if (!this.money_type && !val) {
        this.formData.money_type = ''
      }
    },
    'formData.shipping_type'(val) {
      this.getPostFee(this.getPostFeeflag)
    },
    // 定制 赠品备注 start
    'resData.specifications'(val) {
      // this.firstDetails = val && val.length > 0 && val[0].data ? val[0].data : []
      // this.secondDetails = this.firstDetails && this.firstDetails[0].data ? this.firstDetails[0].data : []
      // this.showCategory = val && val.length > 0 ? val[0].name : ''
      // this.showFirst = this.firstDetails.length > 0 ? this.firstDetails[0].name : ''
      // this.showSecond = this.secondDetails.length > 0 ? this.secondDetails[0].name : ''
    },
    // 定制 备注 end
    is_virtual_payment(val) {
      this.is_use_virtual_currency = true
    },
    is_point_payment(val) {
      this.is_use_integral = true
    },
    reCountPrice(newval, oldval) {
      if (newval != oldval && (this.is_use_coupons || this.is_use_virtual_currency || this.is_use_integral)) {
        // 获取运费后重置优惠券、积分、虚拟币状态
        this.is_use_coupons = false
        this.is_use_integral = false
        this.is_use_virtual_currency = false
        this.getPostFee(true)
      }
    }
  },
  computed: {
    prosImg() {
      return this.formData.id_pros || this.idCard1
    },
    consImg() {
      return this.formData.id_cons || this.idCard2
    },
    reCountPrice() {
      this.isShowPayment = true
      this.isShowOtherPayment = true
      const resData = this.resData
      let totalPrice = this.not_bmd_goods_all_price
      if (this.isGroup == 1) {
        totalPrice = this.totalPrice
      }
      // console.log(44444444)
      // console.log(this.isGroup)
      // console.log(totalPrice)
      // // console.log(totalPrice)
      let postFee = Number(this.postFee)
      // 积分抵用
      const point_cash = Number(resData.point_cash)
      let integral_price = resData.point_payment
      let point_cash_cache = this.point_cash_cache
      let point_cash_limit_percent = resData.point_cash_limit_percent
      point_cash_limit_percent = point_cash_limit_percent == 0 ? 100 : point_cash_limit_percent // 判断积分抵现最高百分比是否为0
      // 虚拟币抵用
      const virtual_cash = Number(resData.virtual_currency_cash)
      const integral_price_virtual = resData.virtual_currency_fee
      let virtual_cash_cache = this.virtual_cash_cache
      let virtual_cash_limit_percent = resData.virtual_cash_max_percent
      virtual_cash_limit_percent = virtual_cash_limit_percent == 0 ? 100 : virtual_cash_limit_percent // 判断虚拟币抵现最高百分比是否为0
      // 是否是首单立减优惠
      const is_firstOrderRemission = resData.is_fist_orderRemission// 是否是首单立减优惠 1 为金额 2为折扣
      let firstOrderRemission_price = resData.firstOrderRemission_price// 首单立减的金额
      let firstOrderRemission_rate = resData.firstOrderRemission_rate // 首单立减比例
      if (firstOrderRemission_rate != '') firstOrderRemission_rate = firstOrderRemission_rate == 0 ? 100 : firstOrderRemission_rate
      const rate = resData.rate
      // 1、是否选择运费到付 如果运费到付 设置运费为0
      if (this.formData.is_freight_collect == 1) {
        postFee = 0.00
      }
      // // console.log(totalPrice, '设置运费为0')
      // 2、加运费
      totalPrice = parseFloat(totalPrice) + parseFloat(postFee)

      // // console.log(totalPrice, '2、加运费')

      // 3、 -优惠券 -供应商优惠券 -优惠码 -供应商优惠码
      totalPrice = totalPrice - this.couponPrice - this.couponSupPrice - this.couponCodePrice - this.dzCouponCodePrice
      // // console.log(totalPrice, '优惠券')

      // 4、商品可抵现金额随该条件而改变 （当商品积分小于可用积分时）
      // // console.log(point_cash_cache)
      if (point_cash != 0) {
        point_cash_cache = (totalPrice - postFee) * (point_cash_limit_percent / 100) * 100 / 100
        const point_val = Math.ceil(point_cash_cache / (point_cash / 100))
        if (point_val <= resData.user_points && !this.formData.is_point_limit_money) {
          point_cash_cache = parseFloat(point_cash_cache.toFixed(2))
        } else {
          point_cash_cache = this.point_cash_cache
          if ((parseFloat(totalPrice) - parseFloat(postFee)) < this.point_cash_cache) {
            point_cash_cache = parseFloat(totalPrice) - parseFloat(postFee)
          }
          if (point_cash_cache < 0) {
            point_cash_cache = 0
          }
          point_cash_cache = parseFloat(point_cash_cache).toFixed(2)
          // point_cash_cache = parseFloat((resData.user_points * (point_cash / 100)).toFixed(2))
        }
      }
      if (integral_price && point_cash_cache > integral_price) {
        point_cash_cache = integral_price
      }
      // 判断是否开启抵现取整
      if (!resData.dz_cash_point && resData.is_point_expense_way != 0) {
        switch (Number(resData.point_expense_way)) {
          case 1:
            point_cash_cache = Math.ceil(point_cash_cache)
            integral_price = Math.ceil(integral_price)
            break
          case 2:
            point_cash_cache = Math.floor(point_cash_cache)
            integral_price = Math.floor(integral_price)
            break
          case 3:
            point_cash_cache = Math.round(point_cash_cache)
            integral_price = Math.round(integral_price)
            break
        }
      }
      // (1111/(20 / 100))
      this.point_cash_cache = point_cash_cache > 0 ? point_cash_cache : 0
      this.formData.user_points = Math.ceil(point_cash_cache / (point_cash / 100)) > 0 ? Math.ceil(point_cash_cache / (point_cash / 100)) : 0
      this.old_total = totalPrice
      // 判断是否选用积分抵用
      if (this.is_point_payment) {
        if (this.isItemPointCashPercent) {
          totalPrice = totalPrice - Number(this.point_payment_cj)
        } else {
          totalPrice = totalPrice - point_cash_cache
        }
        if (totalPrice <= 0) {
          this.isShowPayment = false
          this.isShowOtherPayment = false
          this.money_type = true
        }
        this.formData.is_point_payment = 'on'
      } else {
        this.formData.is_point_payment = ''
      }
      this.formData.point_payment = point_cash_cache
      // // console.log(totalPrice, '判断是否开启抵现取整')

      // 5、虚拟币
      if (virtual_cash != 0) {
        virtual_cash_cache = (totalPrice - postFee) * (virtual_cash_limit_percent / 100 * 100) / 100
        virtual_cash_cache = parseFloat(virtual_cash_cache.toFixed(2))
        if (resData.virtual_currency_fee < virtual_cash_cache) {
          virtual_cash_cache = resData.virtual_currency_fee
        }
      }
      if (integral_price_virtual && virtual_cash_cache > integral_price_virtual) {
        virtual_cash_cache = integral_price_virtual
      }
      this.virtual_cash_cache = virtual_cash_cache > 0 ? virtual_cash_cache : 0
      this.formData.user_virtual = Math.ceil(virtual_cash_cache / (virtual_cash / 100)) > 0 ? Math.ceil(virtual_cash_cache / (virtual_cash / 100)) : 0
      // 判断是否选用虚拟币抵用
      if (this.is_virtual_payment) {
        // // 使用虚拟币抵用的时候看有没有运费
        // let sumTotalPrice = 0
        // if (this.formData.is_freight_insurance == 1) {
        //   let insuranceNum = parseFloat(resData.freight_insurance).toFixed(2)
        //   insuranceNum = insuranceNum > 0 ? insuranceNum : 0
        //   sumTotalPrice = totalPrice + Number(insuranceNum)
        // }
        totalPrice = totalPrice - virtual_cash_cache
        if (totalPrice <= 0) {
          this.isShowPayment = false
          this.isShowOtherPayment = false
        }
        this.formData.is_virtual_payment = 'on'
      } else {
        this.formData.is_virtual_payment = ''
      }
      this.formData.virtual_payment = virtual_cash_cache
      // // console.log(totalPrice, '判断是否选用虚拟币抵用')
      if (this.buyLists.length == 1) {
        const item = this.buyLists[0]
        const c_point = item.consum_point / 1
        const c_precent = item.consum_point_pct / 1
        const num = item.num
        if (c_point != 0) {
          this.consumPoints = Number(c_point) * num
        } else if (c_precent != 0) {
          this.consumPoints = parseFloat(c_precent * totalPrice / 100)
        } else if (this.resData.user_level_point && Number(this.resData.user_level_point) > 0) {
          this.consumPoints = parseFloat(this.resData.user_level_point * totalPrice)
        }
        if (c_point == 0 && c_precent == 0) {
          this.subArr.push(1)
        } else {
          this.subArr.push(0)
        }
      }
      let sendPoint = 0
      // 6、消费积分换算
      if (this.consumPoints != 0) { // 固定积分
        if (this.subArr.includes(1)) {
          if (resData.user_level_point && Number(resData.user_level_point) > 0) {
            sendPoint = parseInt(this.consumPoints)
            // 0 向下取整 1向上取整 2四舍五入
            if (this.point_calculation_rule == '0') {
              sendPoint = Math.floor(this.consumPoints)
            } else if (this.point_calculation_rule == '1') {
              sendPoint = Math.ceil(this.consumPoints)
            } else if (this.point_calculation_rule == '2') {
              sendPoint = Math.round(this.consumPoints)
            }
          } else {
            const surplusTotalPrice = totalPrice - parseFloat(this.consumPrices) // 计算后的商品总价（无积分抵用）
            // 0 向下取整 1向上取整 2四舍五入
            if (this.point_calculation_rule == '0') {
              sendPoint = Math.floor(surplusTotalPrice * rate + this.consumPoints)
            } else if (this.point_calculation_rule == '1') {
              sendPoint = Math.ceil(surplusTotalPrice * rate + this.consumPoints)
            } else if (this.point_calculation_rule == '2') {
              sendPoint = Math.round(surplusTotalPrice * rate + this.consumPoints)
            }
          }
        } else {
          // 0 向下取整 1向上取整 2四舍五入
          if (this.point_calculation_rule == '0') {
            sendPoint = Math.floor(this.consumPoints)
          } else if (this.point_calculation_rule == '1') {
            sendPoint = Math.ceil(this.consumPoints)
          } else if (this.point_calculation_rule == '2') {
            sendPoint = Math.round(this.consumPoints)
          }
        }
      } else if (resData.user_level_point && Number(resData.user_level_point) > 0) { // 其次判断会员等级
        // 0 向下取整 1向上取整 2四舍五入
        if (this.point_calculation_rule == '0') {
          sendPoint = Math.floor(totalPrice * resData.user_level_point)
        } else if (this.point_calculation_rule == '1') {
          sendPoint = Math.ceil(totalPrice * resData.user_level_point)
        } else if (this.point_calculation_rule == '2') {
          sendPoint = Math.round(totalPrice * resData.user_level_point)
        }
      } else {
        // 换算后的积分
        // 0 向下取整 1向上取整 2四舍五入
        if (this.point_calculation_rule == 0) {
          sendPoint = Math.floor(totalPrice * rate)
        } else if (this.point_calculation_rule == 1) {
          sendPoint = Math.ceil(totalPrice * rate)
        } else if (this.point_calculation_rule == 2) {
          sendPoint = Math.round(totalPrice * rate)
        }
      }
      this.sendPoint = sendPoint
      // // console.log(totalPrice, '6、消费积分换算')

      // 7、+ 运费险
      if (this.formData.is_freight_insurance == 1) {
        let insuranceNum = parseFloat(resData.freight_insurance).toFixed(2)
        insuranceNum = insuranceNum > 0 ? insuranceNum : 0
        totalPrice = totalPrice + Number(insuranceNum)
      }
      // // console.log(totalPrice, '运费险')

      // 8、+ 税费
      if (this.formData.is_invoice_type != 1) {
        const buyTaxTnvoice = parseFloat(resData.buy_tax_invoice) / 100 // 税点
        const goodsPrice = resData.before_payment
        const taxPrice = goodsPrice * buyTaxTnvoice
        totalPrice = totalPrice + taxPrice
        this.taxPrice = Number(taxPrice).toFixed(2)
      }
      // // console.log(totalPrice, '税费')
      // 9、判断是否有首单立减优惠
      if (is_firstOrderRemission && is_firstOrderRemission > 0) {
        if (firstOrderRemission_price || firstOrderRemission_rate) {
          // const goodsPrice = resData.before_payment
          // 首单立减减金额
          if (is_firstOrderRemission == 1) {
            firstOrderRemission_price = parseFloat(firstOrderRemission_price)
            totalPrice = totalPrice - firstOrderRemission_price
          } else { // 首单立减百分比
            firstOrderRemission_rate = parseFloat(100 - firstOrderRemission_rate) / 100
            totalPrice = totalPrice * firstOrderRemission_rate
          }
        }
      }
      // // console.log(totalPrice, '9、判断是否有首单立减优惠')

      // 10、判断是否有用优惠抵运费
      if (resData.is_coupon_postfee == 1) { // 可以抵扣运费
        totalPrice = totalPrice > 0 ? totalPrice : 0
      } else { // 不可以抵扣运费
        totalPrice = totalPrice > postFee ? totalPrice : postFee
      }
      // // console.log(totalPrice, '判断是否有用优惠抵运费')

      // 10、自提去掉运费
      if (resData.scanCode == 1) { // 自提
        totalPrice = totalPrice - postFee
      }

      totalPrice = totalPrice > 0 ? totalPrice : 0
      // // console.log(totalPrice, '10、自提去掉运费')
      // 12、薇曼 定制
      if (this.resData.dz_wm_total) {
        this.formData.dz_balance = Number(totalPrice - (this.resData.before_payment - this.resData.dz_wm_total)).toFixed(2)
        this.formData.dz_online = totalPrice
        if (this.formData.money_type == 2) {
          totalPrice = this.formData.dz_balance
          this.isDzWm = true
        } else {
          this.isDzWm = false
        }
      }

      // 11、判断是否显示其他支付
      if (this.formData.money_type == '') {
        // 薇曼定制
        this.formData.dz_wm_type = 1
        this.eddprice = totalPrice
      } else if (this.formData.money_type == 2) {
        this.eddprice = Number(totalPrice - this.user_balance).toFixed(2)
        // 薇曼定制
        this.formData.dz_wm_type = 0
        if (this.eddprice <= 0 && resData.is_item_support_balance_pay && resData.is_open_balance_pay == 1) {
          this.isShowOtherPayment = false
        }
      } else if (this.formData.money_type == 3) {
        this.eddprice = Number(totalPrice - this.resData.dhs_deposit).toFixed(2)
        // 薇曼定制
        this.formData.dz_wm_type = 0
        if (this.eddprice <= 0) {
          this.isShowOtherPayment = false
        }
      }
      this.formData.getPost = Number(totalPrice - postFee).toFixed(2)
      this.formData.payment = Number(totalPrice).toFixed(2)
      // 汇付
      if (this.resData.is_adapay_pay) {
        // console.log('this.resData.user_balance - 0 < totalPrice - 0', this.resData.user_balance - 0 < totalPrice - 0, this.resData.user_balance, totalPrice)
        if (this.resData.user_balance - 0 < totalPrice - 0) {
          this.money_type = ''
          // this.tlyeShow = false
          this.hfShowNoPay = true
        } else {
          // this.tlyeShow = true
          this.hfShowNoPay = false
        }
      }
      // 开启通联 余额不足 不显示
      if (this.resData.is_tlfz) {
        this.tlInfobz.is_tlfz = this.resData.is_tlfz
        this.tlInfobz.is_tlfz_deposit = this.resData.is_tlfz_deposit
        if (this.resData.user_balance - 0 < totalPrice - 0) {
          // console.log('通联余额 buzu ')
          this.money_type = ''
          this.tlyeShow = false
          this.tlInfobz.is_ye = 0
        } else {
          this.tlyeShow = true
        }
      }
      // 百佳华
      if (this.resData.bjh_balance_dz) {
        if (this.resData.user_balance - 0 <= totalPrice - 0) {
          // console.log('百佳华余额 buzu ')
          this.money_type = ''
          this.tlyeShow = false
        } else {
          this.tlyeShow = true
        }
      }
      return Number(totalPrice).toFixed(2)
    },
    // 获取自定义符号
    ...mapGetters(['mSymbol'])
  },
  methods: {
    tlSubmit() {
      this.$refs.payments.payTypeFn()
      this.istl = true
      this.init()
    },
    // 点击使用最大优化
    handleClickMaxCoupon() {
      const pointDefault = this.pointDefault
      this.formData.user_points = pointDefault.user_points
      this.point_cash_cache = pointDefault.point_cash_cache
      this.formData.user_coupon_id = this.resData.max_coupon_amount.user_coupon_id
      this.showPopTips = false
      this.is_use_coupons = true
    },
    // 余额支付切换 小程序滚动到底部
    handleChangeBalance() {
        if (!this.money_type) {
          document.querySelector('.order-buy').$$getBoundingClientRect().then(res =>{
            wx.pageScrollTo({
              scrollTop: res.height
            })
          })
        }
    },
    handleChangeEntity(val) {
      if (val) {
        this.is_dhs_virtual_disabled = true
      } else {
        this.is_dhs_virtual_disabled = false
      }
    },
    // 是否购买虚拟库存
    handleChangeVirtual(val) {
      if (val) {
        if (this.resData.is_dhs_consumer_reward == 1) {
          this.is_show_dhs_virtual_point = true
        } else {
          this.is_show_dhs_virtual_point = false
        }
        this.is_buy_dhs_entity_disabled = true
      } else {
        this.is_buy_dhs_entity_disabled = false
        this.is_show_dhs_virtual_point = false
      }
      // // console.log(this.is_dhs_virtual, '虚拟库存')
      const postFee = this.resData.post_fee
      if (this.is_dhs_virtual) { // 不计算运费
        this.postFee = 0
        // 是否购买虚拟库存
        if (this.resData.dhs_virual_stock_error == 1) {
          this.isShowVirualStock = true
        }
      } else {
        this.postFee = postFee
      }
    },
    onGetLatLng(val) {
      this.formData.latitude = val.lat
      this.formData.longitude = val.lng
      // 门店服务地址列表
      const $refDlgCpt = this.$refs['store-serve-addr-dlg-cpt']
      // console.log('$refDlgCpt:', $refDlgCpt)
      if ($refDlgCpt) {
        $refDlgCpt.selfAddressCountFn('auto', val.lat, val.lng)
      }
    },
    init() {
      const data = Store.fetch('orderBuy')

      // console.log('调试tx_trace_key')
      // console.log(small.wxCache('tx_trace_key'))
      if (this.$route.query.group) {
        this.isGroup = 1
        this.getData(getGroupOrderBuyData, data)
      } else {
        this.getData(getOrderBuyData, data)
      }
    },
    // 定制 赠品 更改品类
    onShowItem(data) {
      this.firstDetails = data.data ? data.data : []
      this.secondDetails = this.firstDetails.length > 0 && this.firstDetails[0].data ? this.firstDetails[0].data : []
      this.showCategory = data.name
      this.showFirst = this.firstDetails.length > 0 ? this.firstDetails[0].name : ''
      this.showSecond = this.secondDetails.length > 0 ? this.secondDetails[0].name : ''
    },
    // 定制 赠品 更改规格 1
    onShowSkuFirst(data) {
      this.secondDetails = data.data ? data.data : []
      this.showFirst = data.name
      this.showSecond = this.secondDetails ? this.secondDetails[0].name : ''
    },
    // 定制 赠品 更改规格 2
    onShowSkuSecond(data) {
      this.showSecond = data
    },
    onGetLocation(change, val) {
      this.isDingWei = false
      wx.getLocation({
        type: 'gcj02',
        success: (res) => {
          // console.log(res, '定位成功')
          this.formData.latitude = res.latitude
          this.formData.longitude = res.longitude
          this.isDingWei = true
          // this.init()
          // 门店服务地址列表
          const $refDlgCpt = this.$refs['store-serve-addr-dlg-cpt']
          // console.log('<<<<<<<<<>>>>>>>>>>>', $refDlgCpt)
          this.allowGetLocation = true
          if ($refDlgCpt) {
            $refDlgCpt.selfAddressCountFn('auto', this.formData.latitude, this.formData.longitude)
          }
          // if (change == 'getSelfAddress') {
          //   // 门店配送设置配送范围，选择地址范围大于设置配送的范围时，提示
          //   if (val) {
          //     if (this.formData.shipping_type == 5 && val.distribute_distance > 0) {
          //       if (val.distribute_distance < val.distance) {
          //         this.$Error('超出配送范围，请重新选择地址')
          //         return false
          //       }
          //     }
          //   }
          //   this.selfAddressInfo = val
          // }
        },
        fail: (resp) => {
          // 代表手机没有开启手机定位权限
          if (resp.errMsg == 'getLocation:fail system permission denied' || resp.errMsg == 'getLocation:fail:ERROR_NOCELL&WIFI_LOCATIONSWITCHOFF') {
            this.$Error('请开启手机定位，以便体验更好的服务')
            // this.init()
            this.allowGetLocation = false
            this.isDingWei = true
          } else {
              wx.getSetting({
                success (res) {
                  if (!res.authSetting['scope.userLocation']) {
                    Dialog.alert({
                      title: '温馨提示',
                      message: '小程序将获取您的授权用来显示位置信息',
                      className: 'wxPop'
                    }).then(() => {
                      // console.log('点击了确认');
                      wx.openSetting({
                        success (res) {
                          // console.log(res.authSetting)
                          res.authSetting = {
                            "scope.userInfo": true,
                            "scope.userLocation": true
                          }
                        }
                      })
                    });
                    // wx.showModal({
                    //   title:'温馨提示',
                    //   content:'小程序将获取您的授权用来显示位置信息',
                    //   showCancel: false,
                    //   success(res){
                    //     if(res.confirm){
                    //       // console.log('点击了确认');
                    //       wx.openSetting({
                    //         success (res) {
                    //           // console.log(res.authSetting)
                    //           res.authSetting = {
                    //             "scope.userInfo": true,
                    //             "scope.userLocation": true
                    //           }
                    //         }
                    //       })
                    //     }
                    //   }
                    // })
                  }
                }
              })
          }
          // console.log(resp, '定位失败')
        }
      })

    },
    // 订单结算
    getData(method, data) {
      this.$loadingWrap.show()
      this.resData = {}
      method(data).then((res) => {
        this.$loadingWrap.close()
        if (res.status == 1) {
          const resData = res.data
          this.resData = res.data
          this.point_calculation_rule = resData.point_calculation_rule
          this.itemIsCod = resData.is_cod
          this.isItemPointCashPercent = resData.isItemPointCashPercent || 0
          this.user_points_cj = resData.user_points || 0
          this.point_payment_cj = resData.point_payment || 0
          this.point_cash_cj = resData.point_cash || 0
          // 备注信息
          if (resData.is_purchase_notes == 1) {
            var oPurchaseInfo = resData.purchase_info
            oPurchaseInfo.forEach(item => {
              item['purchase_value'] = ''
            })
            this.purchaseInfoData = oPurchaseInfo
          }
          // 奇异国预存款定制
          this.is_yck_dz = resData.is_yck_dz
          if (this.is_yck_dz == 1) {
            this.dhs_virtual_txt = '配货到我的云仓'
          }
          // 广州加个番茄 定制
          if (resData.is_item_room_dz && resData.is_item_room_dz == 1) {
            this.is_dz_fq = 1
          }
          // 发票
          if (this.resData.last_time_invoice_info) {
            const invoice_info = this.resData.last_time_invoice_info
            this.formData.invoice_header = invoice_info.invoice_header
            this.formData.invoice_type = invoice_info.invoice_type
            this.formData.invoice_no = invoice_info.invoice_no
            if (invoice_info.is_electronic == 1 && resData.electronic_invoice_enable == 1) {
              this.invoiceInfo = '电子发票'
              this.formData.is_invoice_type = 4
              this.formData.mail = invoice_info.mail
            } else {
              if (invoice_info.type == 1 && resData.paper_invoice_enable == 1) {
                this.invoiceInfo = '纸质发票'
                this.formData.is_invoice_type = 2
              } else if (invoice_info.type == 2 && resData.vat_invoice_enable == 1) {
                this.invoiceInfo = '增值税发票'
                this.formData.is_invoice_type = 3
                this.formData.company_address = invoice_info.company_address
                this.formData.company_phone = invoice_info.company_phone
                this.formData.open_bank = invoice_info.open_bank
                this.formData.bank_account = invoice_info.bank_account
              } else {
                this.invoiceInfo = '不开发票'
                this.formData.is_invoice_type = 1
              }
            }
          } else {
            // 不需要开发票
            this.formData.is_invoice_type = 1
          }
          // 定制 赠品 绑定备注系列
          if (resData.specifications && resData.specifications.length > 0) {
            this.firstDetails = resData.specifications[0].data ? resData.specifications[0].data : []
            this.secondDetails = this.firstDetails.length > 0 && this.firstDetails[0].data && this.firstDetails[0].data.length > 0 ? this.firstDetails[0].data : []
            this.showCategory = resData.specifications[0].name
            this.showFirst = this.firstDetails.length > 0 ? this.firstDetails[0].name : ''
            this.showSecond = this.secondDetails.length > 0 ? this.secondDetails[0].name : ''
          }
          this.is_store_serve_choose = this.resData.is_store_serve_choose
          this.user_info = resData.user_info
          this.self_user_info = resData.self_user_info
          if (this.user_info) {
            this.formData.virtual_username = this.user_info.name || ''
            this.formData.virtual_phone = this.user_info.mobile || ''
          }
          this.order_extry = resData.order_extry
          this.item_config = resData.item_config
          this.used_promotion_type = resData.used_promotion_type
          this.is_dz_op = resData.is_dz_op
          this.isGroupShopping = resData.isGroupShopping
          this.formData.id_pros = resData.card_img[0]
          this.formData.id_cons = resData.card_img[1]
          if (resData.card_img && resData.card_img.length >= 2) {
            this.cardImgArr1 = [resData.card_img[0]]
            this.cardImgArr2 = [resData.card_img[1]]
          }
          this.list_shipping = resData.list_shipping
          this.buyLists = resData.buy_lists
          this.coupon_lists = resData.coupon_lists
          this.coupon_lists_ZJHL_DZ = resData.coupon_lists_ZJHL_DZ
          this.totalPrice = resData.payment // 商品总价
          this.is_bmd_discount = resData.is_bmd_discount // 多买优惠不参与优惠叠加
          this.is_display_bmd_desc = resData.is_display_bmd_desc // 是否显示‘多买优惠商品不支持优惠叠加’
          this.not_bmd_goods_all_price = resData.not_bmd_goods_all_price // 非多买优惠的商品总价
          this.bmd_goods_all_price = resData.bmd_goods_all_price || 0 // 多买优惠商品总价
          this.postFee = parseFloat(resData.post_fee).toFixed(2) // 运费
          this.pointDefault = {
            user_points: resData.user_points,
            point_cash_cache: resData.point_payment
          }
          this.formData.user_points = resData.user_points
          this.point_cash_cache = resData.point_payment// 积分抵用金额
          this.formData.user_virtual = resData.virtual_currency_num // 虚拟币抵用数量
          this.virtual_cash_cache = resData.virtual_currency_fee // 虚拟币抵用金额
          this.user_balance = parseFloat(resData.user_balance)
          this.is_dhs_virtual = resData.is_dhs_virtual
          this.is_wx_pay_h5 = resData.is_wx_pay_h5

          this.formData.list_shipping_id = resData.list_shipping_id || 0

          // 默认勾选余额支付
          if (this.user_balance != 0 && this.resData.is_item_support_balance_pay && this.resData.is_open_balance_pay == 1) {
            this.money_type = true
            // 汇付 不允许混合支付
            if (resData.is_adapay_pay) {
              if (resData.user_balance - 0 < resData.payment - 0) {
                this.money_type = ''
                // this.tlyeShow = false
                this.hfShowNoPay = true
              } else {
                this.money_type = true
                // this.tlyeShow = true
                this.hfShowNoPay = false
                this.paymentWay = 'cancel'
              }
            }
          }
          this.must_pay_password = resData.must_pay_password // 是否强制输入支付密码
          this.shop_info = resData.shop_info
          this.itemIds = []
          this.sku_id = []
          this.sku_name = []
          this.current_price = []
          this.is_first_gift = []
          this.num = []
          this.active = []
          this.buy_gift_type = []
          this.dollar_price = []
          this.sup_post_fee = []
          this.new_supplier_id = []
          this.supplier_ids = []
          this.subArr = []
          let countNum = 0
          this.buyLists.forEach((item, indx) => {
            this.itemIds.push(item.item_id)
            this.sku_id.push(item.sku_id)
            this.sku_name.push(item.props)
            this.current_price.push(item.price)
            this.is_first_gift.push(item.is_first_gift)
            this.num.push(item.num)
            this.active.push(item.active)
            this.buy_gift_type.push(item.buy_gift_type)
            this.dollar_price.push(item.dollar_price)
            this.sup_post_fee.push(item.sup_post_fee)
            this.new_supplier_id.push(item.new_supplier_id)
            if (item.new_supplier_id) {
              this.supplier_ids.push(item.new_supplier_id)
            }

            // 医疗定制 是否包含处方药 start
            if (item.is_prescription_drug) {
              this.prescription_drug = true
              this.medical_patient_item_id = item.item_id
            }
            // 医疗定制 是否包含处方药 end

            // 跨境商品不可选择自提或门店配送，不能使用余额、预存款、积分抵现、虚拟币抵现
            if (this.resData.is_open_kuajing == 1) {
              const kuajingtype = item.item_config
              if (kuajingtype && kuajingtype.kuajing_type > 0) {
                // 打开其他支付
                this.money_type = false
                this.money_type2 = false
                // this.isShowOtherPayment = true
                // 不能使用余额、预存款、积分抵现、虚拟币抵现
                this.isKuajing = true
                // 跨境商品不可选择自提或门店配送
                if (this.list_shipping && this.list_shipping['4']) {
                  delete this.list_shipping['4']
                  if (!this.list_shipping) {
                    this.$Error('无可用配送方式,请联系客服')
                  }
                }
                if (this.list_shipping && this.list_shipping['5']) {
                  delete this.list_shipping['5']
                  if (!this.list_shipping) {
                    this.$Error('无可用配送方式,请联系客服')
                  }
                }
              }
            }
            // 若有一个商品不是免物流，则显示运费险
            if (item.is_free_logistics != 1) {
              this.showFreightInsurance()
            } else {
              this.is_free_logistics = true
              this.hideFreightInsurance()
            }
            const c_point = item.consum_point / 1
            const c_precent = item.consum_point_pct / 1
            const num = item.num
            if (c_point != 0) {
              this.consumPrices += parseFloat(item.price * num) // 单个商品的总价
              countNum += parseFloat(c_point * num) // 单个商品送的积分
            } else if (c_precent != 0) {
              this.consumPrices += parseFloat(item.price * num) // 单个商品的总价
              countNum += parseFloat(c_precent * item.price / 100) * num
            } else if (this.resData.user_level_point && parseInt(this.resData.user_level_point) != 0) {
              // 按测试要求改为 会员等级积分 * (单价 * 数量 + 运费)，，，，，原来逻辑为 会员等级积分 * (单价+运费）*数量
              const countPrice = Number(item.price)
              countNum += parseFloat(this.resData.user_level_point * (countPrice * num + parseInt(this.postFee)))
            }
            if (c_point == 0 && c_precent == 0) {
              this.subArr.push(1)
            } else {
              this.subArr.push(0)
            }
            // this.subArr.push(c_point)
          })
          // console.log('countNum', countNum)
          this.consumPoints = countNum
          // 0 向下取整 1向上取整 2四舍五入
          // if (this.point_calculation_rule == 0) {
          //   this.consumPoints = Math.floor(countNum)
          // } else if (this.point_calculation_rule == 1) {
          //   this.consumPoints = Math.ceil(countNum)
          // }
          // else if (this.point_calculation_rule == 2) {
          //   this.consumPoints = Math.round(countNum)
          // }
          // 江西赣中旅 start
          this.is_jxgzl_dz = resData.jxgzl_dz
          // 江西赣中旅 end
          // 供应链定制
          this.is_jh_item_dz = resData.is_jh_item_dz || 0
          // form提交数据
          this.formData.is_freight = resData.is_freight
          if (resData.default_shipping_type) {
            for (const key in resData.list_shipping) {
              if (key == resData.default_shipping_type) {
                this.formData.shipping_type = resData.default_shipping_type
              }
            }
          }
          // fix：定位问题，如果运费模板进来就是自提或者配送，那进来就要授权 否则不需要
          if ((this.formData.shipping_type ==4 ||  this.formData.shipping_type ==5)) {
            this.isDingWei = false
            this.onGetLocation()
          } else {
            this.isDingWei = true
          }
          if (resData.is_need_username_and_mobile == 1) {
            this.isVirtualGoods = true
            this.virtual_add_order_desc = resData.virtual_add_order_desc
          }
          // 定制 得炫定制 start
          this.is_hzdx_dhs_dz = resData.is_hzdx_dhs_dz || 0
          this.dz_package_item_id = resData.dz_package_item_id
          this.dz_package_item_num = resData.dz_package_item_num
          // 定制 得炫定制 end
          this.formData.is_dhs_send = resData.is_dhs_send
          this.formData.id_pros_cons = resData.id_pros_cons
          this.formData.id_pros_cons_one = resData.id_pros_cons_one
          this.formData.is_buy_card = resData.is_buy_card
          this.formData.is_custom_pic = resData.custom_pic
          this.formData.is_one_item = 1
          this.formData.order_source = resData.order_source
          this.formData.live_id = resData.live_id
          this.formData.assort_id = resData.assort_id
          this.formData.item_cycle_buy_id = resData.item_cycle_buy_id
          this.formData.item_cycle_sku = resData.item_cycle_sku
          this.formData.item_cycle_delivery = resData.item_cycle_delivery
          this.formData.is_send_gift = resData.send_gift
          this.formData.max_coupon_value = resData.max_coupon_value
          this.formData.allow_coupon_items = resData.allow_coupon_items
          this.formData.cart_ids = resData.cart_ids
          this.formData.is_user_temp = resData.is_user_temp
          this.formData.receiver_name_dz = resData.receiver_name_dz
          this.formData.receiver_mobile_dz = resData.receiver_mobile_dz
          this.formData.dollar_payment = resData.dollar_payment
          this.formData.code = resData.code
          this.formData.deny_coupon_items = resData.deny_coupon_items
          this.formData.item_miao_id = resData.item_miao_id
          this.formData.item_bargin_id = resData.item_bargin_id
          this.formData.is_store_fn_pt = resData.is_store_fn_pt
          this.formData.scanCode = resData.scanCode
          this.formData.addressId = resData.addressId
          this.formData.streetBtn = resData.is_select_town
          this.formData.total_price = resData.payment
          this.formData.post_price = resData.post_fee
          this.formData.is_point_limit_money = resData.is_point_limit_money
          this.formData.point_cash = resData.point_cash
          this.formData.point_payment_hidden = resData.point_payment
          this.formData.user_points_hidden = resData.user_points
          this.formData.point_expense_way = resData.point_expense_way
          this.formData.is_point_expense_way = resData.is_point_expense_way
          this.formData.point_name = resData.point_name
          this.formData.virtual_cash = resData.virtual_cash
          this.formData.virtual_payment_hidden = resData.virtual_currency_fee
          this.formData.user_virtual_hidden = resData.virtual_currency_num
          this.formData.balance_price = resData.user_balance
          this.formData.must_pay_password = resData.must_pay_password
          this.formData.item_total_num = resData.item_total_num
          this.formData.item_total_weight = resData.item_total_weight
          this.formData.item_total_volume = resData.item_total_volume
          this.formData.freight_tpl_id = resData.freight_tpl_id
          this.formData.group_shopping_id = resData.group_shopping_id
          this.formData.freight_tpl_payment = resData.freight_tpl_payment
          this.formData.point_cash_limit_percent = resData.point_cash_limit_percent
          this.formData.virtual_cash_max_percent = resData.virtual_cash_max_percent
          this.formData.json_real_price = resData.json_real_price
          this.formData.package_active_diff_price = resData.package_active_diff_price
          this.formData.full_mail_is_price = resData.full_mail_is_price
          this.formData.select_last_location = resData.select_last_location
          this.formData.is_id_cert = resData.is_id_cert
          this.is_dataset_json = resData.is_dataset_json
          this.formData.item_id = this.itemIds
          this.formData.sku_id = this.sku_id
          this.formData.sku_name = this.sku_name
          this.formData.current_price = this.price
          this.formData.current_dollar_price = this.dollar_price
          this.formData.sup_post_fee = this.sup_post_fee
          this.formData.new_supplier_id = this.new_supplier_id
          this.formData.is_first_gift = this.is_first_gift
          this.formData.num = this.num
          this.formData.active = this.active
          this.formData.buy_gift_type = this.buy_gift_type
          this.formData.supplier_id = this.supplier_ids
          this.formData.is_store_serve = resData.is_store_serve

          // 顶呱呱定制-虚拟物品要求显示地址 是免物流
          if (this.resData.dingguagua_dz && this.resData.is_freight) {
            this.dingguagua_dz_is_freight = 1
          }
          // 定制  从未健康 start
          if (this.resData.is_cwjk_dz == 1) {
            this.is_dhs_virtual = true
          }
          // 定制  从未健康 end
          // 定制  云集 start
          if (this.resData.is_dhs_check_virual_stock == 1) {
            this.is_dhs_virtual = true
          }

          // 定制  云集 end
          // 十人团 定制 start
          if (this.isGroupShopping && this.isGroupShopping.aggregation_type && this.isGroupShopping.aggregation_type == 6) {
            this.istendz = 1
            this.is_point_payment = true
          } else {
            this.istendz = 0
            this.is_point_payment = false
          }
          // 十人团 定制 end

          // 定制 现金积分 start
          if (resData.dz_cash_point && resData.dz_cash_point_deduct_fee == '') {
            resData.dz_cash_point_deduct_fee = 0
          }
          // 星链供应链
          this.is_star_chain_item_dz = resData.is_star_chain_item_dz || 0
          // 定制 现金积分 end
          // 开启通联 余额不足 不显示
          if (resData.is_tlfz) {
            this.tlInfobz.is_tlfz = resData.is_tlfz
            this.tlInfobz.is_tlfz_deposit = resData.is_tlfz_deposit
            if (resData.user_balance - 0 < resData.payment - 0) {
              // console.log('通联余额 buzu ')
              this.money_type = ''
              this.tlyeShow = false
              this.tlInfobz.is_ye = 0
            } else {
              this.money_type = true
              this.tlyeShow = true
              this.paymentWay = 'cancel'
              this.tlInfobz.is_ye = 1
            }
          }

          const arrDate = []
          const arrMeno = []
          if (Store.fetch('orderBuy') && Store.fetch('orderBuy').type == 'oncart') {
            this.buyLists.forEach(item => {
              arrDate.push({ 'item_date': item.item_date })
              arrMeno.push({ 'item_memo': item.item_memo })
            })
            this.formData.order_extry_date = arrDate
            this.formData.order_extry_memo = arrMeno
          } else {
            if (this.order_extry) {
              arrDate.push({ 'item_date': this.order_extry.item_date })
              arrMeno.push({ 'item_memo': this.order_extry.item_memo })
            }
            this.formData.order_extry_date = arrDate
            this.formData.order_extry_memo = arrMeno
          }
          if (resData.address[0]) {
            if (this.resData.is_buy_card == 1) {
              this.formData.id_card = resData.address[0].id_card
            }
            if (this.resData.is_buy_card == 1 && this.resData.is_id_cert_name == 1) {
              this.formData.id_cert_name = resData.address[0].id_cert_name
            }
            this.formData.e_mail = resData.address[0].email
            this.formData.hasLatLng = !!(resData.address[0].latitude && resData.address[0].latitude)
          }
          this.formData.user_realname = resData.self_user_info.name
          this.formData.user_mobile = resData.self_user_info.mobile

          this.lastRuleByPayment(this.totalPrice)
          this.formData.province_id = resData.province_id
          this.formData.area_id = resData.area_id
          this.formData.city_id = resData.city_id
          this.getPostFee(true)
        } else {
          if (res.msg == 'xgym') {
            this.isShowurPchasingTip = true
            this.handleLimitBuyPage()
          } else {
            Toast(res.msg)
            setTimeout(() => {
              this.$router.go(-1)
              // 小程序跳转编辑资料处理 没有手机号时可以用弹窗优化体验
                if (res.data && res.data.redirect_url) {
                  openPage(res.data.redirect_url)
                } else {
                  wx.navigateBack({
                    delta: 1
                  })
                }
            }, 1000)
          }
        }
      })
    },
    // 获取充值规则
    lastRuleByPayment(payMoney) {
      lastRuleByPayment({ payMoney: payMoney }).then(res => {
        if (res.status == 1) {
          if (res.data.amount > 0) {
            this.isShowchargeAdv = true
            this.chargeAmount = parseFloat(res.data.amount).toFixed(2)
            this.chargeNun = parseFloat(res.data.num).toFixed(2)
          }
        }
      })
    },
    // 是否显示付款详情
    async openPayPop() {
      if (this.prescription_drug && !this.medical_patient_id) {
        this.heightCfy = '70%'
        this.position = 'bottom'
        // this.$Error('请添加处方信息')
        this.type = 'buy'
        this.show_prescriptionInfo = true
        return false
      }
      if (this.isOrder) {
        return false
      }
      if (this.paymentWay == 'wxpay') {
        if (isWeixinCient()) { // 微信环境
          this.formData.type = 2
         if (this.ltnsStatus && this.paymentDataList.is_dhs == 1) {
            delete this.formData.type
          }
        } else { // 非微信环境
          // 开启了微信h5支付
          if (this.is_wx_pay_h5 == 1) {
            this.formData.type = 12
          }
        }
      } else if (this.paymentWay == 'alipay') {
        this.formData.type = 1
      } else if (this.paymentWay == 'Hdfkpay') {
        this.formData.type = 3
      } else if (this.paymentWay == 'jdpay') {
        this.formData.type = 4
      } else if (this.paymentWay == 'PayPalpay') {
        this.formData.type = 5
      } else if (this.paymentWay == 'BeiBaopay') {
        this.formData.type = 6
      } else if (this.paymentWay == 'peerpay') {
        this.formData.type = 7
      } else if (this.paymentWay == 'ylpay') {
        this.formData.type = 8
      } else if (this.paymentWay == 'kqpay') {
        this.formData.type = 9
      } else if (this.paymentWay == 'xxpay') {
        this.formData.type = 10
      } else if (this.paymentWay == 'yeepay') {
        this.formData.type = 11
      } else if (this.paymentWay == 'newyeepay') {
        this.formData.newyeepay = 1
        this.formData.type = 14
      } else if (this.paymentWay == 'cloudPay') { // 定制云闪付
        this.formData.type = 17
      } else if (this.paymentWay == 'globalAlipay') { // 国际支付宝
        this.formData.type = 15
        this.formData.global_alipay_currency = this.global_alipay_currency
      } else if (this.paymentWay == 'htwxpay') { // 定制 hante
        this.formData.type = 16
        this.formData.hantepay = 1
      } else if (this.paymentWay == 'htAlipay') { // 定制 hante
        this.formData.type = 16
        this.formData.hantepay = 2
      } else if (this.paymentWay == 'tlwxpay') { // 通联支付
        this.formData.type = 19
        this.formData.allinpay = 1
      } else if (this.paymentWay == 'tlAlipay') { // 通联支付
        this.formData.type = 19
        this.formData.allinpay = 2
      } else if (this.paymentWay == 'goallpay') { // GoAllPay
        this.formData.type = 20
      } else if (this.paymentWay == 'Alipay') {
        this.formData.type = 21
      } else if (this.paymentWay == 'UnionPay') {
        this.formData.type = 22
      } else if (this.paymentWay == 'WeChatPay') {
        this.formData.type = 23
      } else if (this.paymentWay == 'tlfzWxpay') {
        this.formData.type = 26
      } else if (this.paymentWay == 'HipoWxPay') { // 上海百策定制HipoPay微信支付
        this.formData.type = 27
      } else if (this.paymentWay == 'ytDzWxPay') {
        this.formData.type = 24
      } else if (this.paymentWay == 'JoinWeChatPay') { // 汇聚支付 微信
        this.formData.type = 29
      }else if (this.paymentWay == 'hffzWxpay') { // 汇付分账 微信
        this.formData.type = 34
        this.formData.adapay_pay_type = 2
      } else if (this.paymentWay == 'jhWeChatPay') { // 聚合支付
        this.formData.type = 48
      }
      // 数据处理
      if (this.is_store_stock) {
        this.formData.is_store_stock = 1
      } else {
        this.formData.is_store_stock = 0
      }
      if (this.resData.is_item_agreement == 1) {
        this.formData.is_agree_purchase_agreement = this.agreementId.join(',')
      } else {
        if (this.is_agree_purchase_agreement) {
          this.formData.is_agree_purchase_agreement = 1
        } else {
          this.formData.is_agree_purchase_agreement = 0
        }
      }
      // // console.log(this.formAuthentication())
      // 表单验证中的任何一项失败了或者身份验证失败了，都不能继续往下走
      if (!this.formAuthentication()){
        return false
      }
      if (this.resData.is_buy_card == 1) {
        if (this.formData.id_card == '' || !this.formData.id_card) {
          this.$Error('请输入' + this.resData.card_alias)
          return false
        } else {
          if (this.resData.is_id_cert == 1) {
            let name = ''
            if (this.formData.shipping_type == 4) {
              name = this.formData.user_realname
            } else {
              name = this.address_name
            }
            // 如果有身份证姓名输入框，则验证改姓名和身份证号码
            if (this.resData.is_buy_card == 1 && this.resData.is_id_cert_name == 1) {
              if (this.formData.id_cert_name == '' || !this.formData.id_cert_name) {
                this.$Error('请输入' + this.resData.id_cert_name)
                return false
              } else {
                name = this.formData.id_cert_name
              }
            }
            const data = {
              'id_no': this.formData.id_card,
              'name': name
            }
            const res = await idCert(data)
            if (res.status == -1) {
              this.$Error(res.msg)
              return false
            }
          }
        }
      }

      if ((this.formData.money_type == 2 && this.eddprice <= 0) || this.formData.type == 7) { // 余额支付及货到付款
        // 是否强制使用支付密码
        if (this.must_pay_password == 1) {
          this.$Error('请先去会员中心的修改资料里设置支付密码!')
        } else {
          if (this.formData.money_type == 2 && this.resData.popup_show) {
            this.showPwd = true
          } else {
            this.getTemplateIdFun()
          }
        }
      } else {
        this.getTemplateIdFun()
      }
    },

    // 增加订阅消息模版id渲染
    getTemplateIdFun() {
      this.isSubmit = true
      // this.$loadingWrap.show()
      GetWxTemplateId({type: 'add_order'}).then(data => {
        // this.$loadingWrap.close()
        if (data.status == 1) {
          const datas = data.data
          wx.requestSubscribeMessage({
            tmplIds: datas,
            success: (res) => {
              // console.log(res)
              // 将formdata数据上报后台做记录处理
              let sendData = {};
              sendData.form_data = JSON.stringify(res);
              PostAddWxTemplateId(sendData).then(res => {})
            },
            complete: (res) => { // 不管方法成功与失败都将点击事件丢出
              this.payPwdCallback()
            }
          })
        }
      })
    },

    // 表单验证
    formAuthentication() {
      let flag = true
      // 如果有跨境商品
      // 定制日元限制
      const sid = Store.fetchLocal('sid')
      // console.log(sid)
      if (sid == '8009113') {
        if (document.getElementsByClassName('kj_mark').length > 0 && this.totalPrice > 76000) {
          this.$Error('跨境商品单笔订单金额不得超过76000元，请重新下单')
          flag = false
        }
      } else {
        if (document.getElementsByClassName('kj_mark').length > 0 && this.totalPrice > 5000) {
          this.$Error('跨境商品单笔订单金额不得超过5000元，请重新下单')
          flag = false
        }
      }

      // 定制 江西赣中旅 start
      // 购买协议存在需勾选
      if (this.resData.is_item_agreement == 1) { // 是否开启单个商品购买协议
        if (this.resData.is_open_purchase_agreement == 1 && this.agreementId.length == 0) {
          this.$Error(this.resData.purchase_agreement_tips)
          flag = false
        }
      } else {
        if (this.resData.is_open_purchase_agreement == 1 && !this.is_agree_purchase_agreement) {
          this.$Error(this.resData.purchase_agreement_tips)
          flag = false
        }
      }
      // 开启通联分账，余额和其他支付方式 不能混合支付
      if (this.resData.is_tlfz) {
        if (!this.resData.is_tlfz_deposit && this.formData.money_type) {
          // console.log('2323')
          this.formData.type = ''
        }
        if (this.formData.money_type && this.formData.type == 26 && !this.resData.is_tlfz_deposit) {
          this.$Error('不能混合支付，请检查支付方式')
          return false
        }
        if (this.resData.is_tlfz_deposit && this.formData.money_type) {
          this.formData.type = 26
        }
      }
      if (this.is_jxgzl_dz == 1) {
        if (!this.formData.receiver_name_dz) {
          this.$Error('请填写姓名')
          flag = false
        }
        if (!this.formData.receiver_mobile_dz) {
          this.$Error('请填写手机号')
          flag = false
        }
      } else if (this.isVirtualGoods) {
        if (!this.formData.virtual_username.trim()) {
          this.$Error('请填写姓名')
          flag = false
        }
        if (!this.formData.virtual_phone.trim()) {
          this.$Error('请填写手机号')
          flag = false
        }
      }
      // 定制 江西赣中旅 end
      // 如果勾选了购买虚拟库存,不验证收货地址
      if (!this.is_dhs_virtual) {
        this.formData.is_dhs_virtual = 0
        // 如果不是自提再验证是否填收货地址
        if (this.formData.shipping_type != 4) {
          if (!this.is_free_logistics && this.formData.address_id == '') {
            // 送礼订单is_gift_address == 0 不需要填写收货地址
            if (this.resData.send_gift && this.resData.is_gift_address == 0) {
              // return
              // flag = true
            } else {
              this.$Error('请选择收货地址')
              flag = false
            }
            
          }
        }
      } else {
        this.formData.is_dhs_virtual = 1
      }
      // 顶呱呱定制-虚拟物品要求显示地址-并修改显示文字
      if (this.dingguagua_dz_is_freight && this.formData.address_id == '' && this.formData.shipping_type != 4) {
        this.$Error('请选择收货地址')
        flag = false
      }
      // 门店配送且开启蜂鸟配送时验证地址是否有经纬度
      if (this.formData.shipping_type == 5) {
        if (this.formData.is_store_fn_pt == 1 && !this.formData.hasLatLng) {
          this.$Error('该收货地址无法使用蜂鸟配送，请重新编辑')
          flag = false
        }
      }

      // 身份证正反面
      // TODO 小程序身份证正反面和上传图片用微信上传返回的
      if (this.resData.id_pros_cons) {
          this.formData.id_pros = this.$refs.smallUploadImg1.imgList.length ? this.$refs.smallUploadImg1.imgList[0] : ''
        if (!this.formData.id_pros) {
          this.$Error('请上传' + this.resData.card_alias + '正面照片')
          flag = false
        }
      }
      if (this.resData.id_pros_cons && !this.resData.id_pros_cons_one) {
          this.formData.id_cons = this.$refs.smallUploadImg2.imgList.length ? this.$refs.smallUploadImg2.imgList[0] : ''
        if (!this.formData.id_cons) {
          this.$Error('请上传' + this.resData.card_alias + '反面照片')
          flag = false
        }
      }
      // 如果需要上传图片
      if (!this.resData.id_pros_cons && this.resData.custom_pic && this.resData.custom_pic_num > 0) {
          this.formData.custom_pic = this.$refs.smallUploadImg3.imgList.length ? this.$refs.smallUploadImg3.imgList : []
        if (this.formData.custom_pic.length < 1) {
          this.$Error('请上传至少一张图片')
          flag = false
        }
      }

      // 如果需要填写邮箱
      const mailreg = /^(\w)+(\.\w+)*@(\w)+((\.\w{2,3}){1,3})$/
      if (this.resData.is_order_email == 1) {
        if (mailreg.test(this.formData.e_mail) == false) {
          this.$Error('请输入正确邮箱格式')
          flag = false
        }
      }
      if (this.resData.is_self_mobile == 1 && this.isShowSelfMobile) {
        // TODO 暂时去掉$.trim
        if (!this.formData.user_realname) {
          this.$Error('请输入姓名')
          flag = false
        }
        const mobileReg = /^1\d{10}$/
        if (!mobileReg.test(this.formData.user_mobile)) {
          this.$Error('请输入正确的手机号码')
          flag = false
        }
      }

      // 判断买家留言是否必填
      if (this.resData.is_buyer_message == 1) {
        // TODO 暂时去掉$.trim
        if (!this.formData.message) {
          this.$Error('请输入买家留言')
          flag = false
        }
      }

      // console.log(this.paymentWay)
      // console.log(this.formData.type)
      if (this.formData.type == '' && this.formData.money_type == '' && this.isShowPayment) {
        this.$Error('请选择支付方式')
        flag = false
      } else {
        if (this.resData.is_ahxh_dz == 1) {
          this.ahxh_dz()// 定制  安徽协和
        }

        // h5在小程序环境webview中
        if (window.__wxjs_environment === 'miniprogram') {
          // 定制：欧普。小程序环境
          this.formData.is_op_dzxcx_pay = 1
        }
      }

      // 备注检验
      if (this.resData.is_purchase_notes == 1) {
        const keyArr = []
        const valueArr = []
        this.purchaseInfoData.forEach((item, index) => {
          // console.log(item.purchase_value)
          if (item.checked == 1 && !item.purchase_value) {
            this.$Error('请填写带星号的必填项！')
            flag = false
          } else {
            keyArr.push(item.key_value)
            valueArr.push(item.purchase_value)
            this.formData[item.key_name] = keyArr
            this.formData[item.value_name] = valueArr
          }
        })
      }

      return flag
    },
    // 输入支付密码点击确定
    payPwdCallback() {
      if (this.$route.query.group) {
        this.formData.groupShoppingId = this.isGroupShopping.id
        this.formData.realItemId = this.isGroupShopping.item_id
        this.formData.tuanId = this.resData.tuanId
        this.formData.tuanOrderId = this.resData.tuanOrderId
        this.GroupShoppingOrder()
      } else {
        this.clickSubmitOrder()
      }
    },
    // 关闭输入支付密码弹窗
    closePwd() {
      this.showPwd = false
    },
    // 提交订单
    clickSubmitOrder() {
      const data = Store.fetch('orderBuy')
      // console.log(data, '提交订单打印')
      // 交易组件小程序需要传输特殊的场景值 交易组件的场景值是 1175 1177
      this.formData.ministore_scene = small.wxCache('scene')
      if (this.is_buy_dhs_entity) {
        this.formData.is_buy_dhs_entity = 1
      }
      // 定制 得炫 start
      if (this.is_hzdx_dhs_dz) {
        this.formData.dz_package_item_id = this.dz_package_item_id
        this.formData.dz_package_item_num = this.dz_package_item_num
        // this.formData.item_id = []
        // this.formData.num = []
        // this.formData.item_id.push(this.dz_package_item_id)
        // this.formData.num.push(1)
        // this.formData.sku_id = undefined
        // this.formData.current_dollar_price = undefinedx
      }
      // 定制 得炫 end
      // 定制 鼎兴餐饮 传专属字段 ‘组合套餐主商品id’
      const buyData = Store.fetch('orderBuy')
      if (buyData.is_dxcy_gift_dz && buyData.is_dxcy_gift_item_id) {
        this.formData.is_dxcy_gift_item_id = buyData.is_dxcy_gift_item_id
      }
      // 微视的key
      this.formData.tx_trace_key = small.wxCache('tx_trace_key')
      if (this.formData.type == 26 && this.money_type) {
        this.formData.tlfz_pay_type = 4
      }
      if (this.paymentDataList.tlfz_deposit == 1 && this.money_type && this.formData.payment > 0 && this.paymentDataList.is_need_change_bind_phone) {
        this.$refs.tlInfo.handleShow({
          ishow: true
        })
        // console.log(this.paymentDataList)
        this.isSubmit = false
        return false
      }
      if (data.group_solitaire_activity_id) this.formData.group_solitaire_activity_id = data.group_solitaire_activity_id

      // 处方药
      if (this.prescription_drug) {
        if (!this.medical_patient_id) {
          this.heightCfy = '70%'
          this.position = 'bottom'
          // this.$Error('请添加处方信息')
          this.type = 'buy'
          this.show_prescriptionInfo = true
          return false
        }
        this.formData.medical_patient_id = this.medical_patient_id
      }
      // 处方药问诊  不用余额支付
      if (this.resData.is_need_consultation == 1) {
        this.formData.money_type = ''
      }

      // 运费模板金额计算新规则所需参数
      this.formData.amount_after_discount = this.reCountPrice - this.postFee
      // 定制 赠品规格需要拼接在买家留言字段中 start
      if (this.resData.specifications && this.resData.specifications.length > 0) {
        const message = `赠送商品规格：${this.showCategory}  ${this.showFirst}  ${this.showSecond}`
        this.formData.message = this.formData.message ? `${this.formData.message}（${message}）` : message
      }
      // json
      if (this.is_dataset_json == 1) {
        this.anh_dz()
      }
      // console.log('this.formData.message', this.formData.message)
      // 定制 赠品规格需要拼接在买家留言字段中 end
      addOrder(this.formData).then((res) => {
        // console.log(res, 'addOrder')
        // this.isSubmit = false
        if (res.status == 1) {
          this.order_id = res.data.order_id

          // 处方药定制 跳转h5问诊start
          // if (res.data.is_need_consultation == 1) {
          //   const order_id = res.data.order_id
          //   this.jumpConsulationUrl(order_id)
          //   return
          // }
          // 处方药定制 跳转h5问诊end

          // 微信支付
          if (this.formData.type == 27 && res.data.HipoPayParams) {
            // HipoPay 微信支付
            // console.log(res.data.HipoPayParams)
            this.isSubmit = false
            smllpay.wxOrderPay(res.data.HipoPayParams)
          } else if ((this.formData.type == 2 || this.formData.type == 19 || (this.formData.type == 26 && !res.data.is_mini_vsp) || this.formData.type == 29 || this.formData.type == 48) && res.data.jsApiParameters) {
            this.isSubmit = false
            smllpay.wxOrderPay(res.data.jsApiParameters)
          } else if (this.formData.type == 26 && res.data.is_mini_vsp) {
            this.isSubmit = false
            this.Jump('/buyTonglianWait',{ order_id: res.data.order_id, pay_type: 1 })
          }
          // TODO 跳转
          if (res.data && res.data.redirect_url) {
            // TODO 不为代付时才提示
            if (this.paymentWay != 'peerpay' && res.data.is_need_consultation != 1) {
              this.$Error('支付成功')
            }
            setTimeout(() => {
              openPage(res.data.redirect_url)
            }, 1000)
          }
          // 通联余额支付
          if (this.formData.type == 26 && this.money_type) {
            this.isSubmit = false
            this.$refs.sendCodePayment.handleShow({
              order_id: res.data.order_id,
              tlfz_pay_type: this.formData.tlfz_pay_type
            })
          }
          if (this.formData.type == 34) {
            if (small.wxCache('adapayPlugVersion') == 'jump_adapay_mini') {
              const jsApiParameters = typeof res.data.jsApiParameters === 'object' ? res.data.jsApiParameters : JSON.parse(res.data.jsApiParameters)
              this.hfAppId = jsApiParameters.wx_app_id
              const that = this
              wx.navigateToMiniProgram({
                appId: jsApiParameters.wx_app_id,
                path: jsApiParameters.miniapp_path,
                success(res) {
                  // 打开成功
                  // console.log(res)
                },
                fail(error) {
                  // that.$Error('跳转失败')
                  that.Jump('buySuccess', {id: res.data.order_id})
                }
              })
            } else if (small.wxCache('adapayPlugVersion') == 'self') {
              this.isSubmit = false
              smllpay.wxOrderPay(res.data.jsApiParameters)
            } else {
              const adapayPlugin = small.wxCache('adapayPlugVersion') == 'new' ? requirePlugin("Adapay") : requirePlugin("adapay-plugin")
              // 汇付分账
              this.isSubmit = false
              // console.log('typeof obj',  typeof res.data.jsApiParameters === 'object')
              const hfPay= res.data.jsApiParameters
              if (hfPay) {
                adapayPlugin.requestPay(hfPay, this.paySuccess, this.payError);
              }
            }
          }
          // window.location.href = res.data.redirect_url
        } else {
          this.isSubmit = false


          // 限购商品提示
          if (res.msg == 'xgym') {
            this.isShowurPchasingTip = true
            this.handleLimitBuyPage()
          } else {
            Toast(res.msg)
          }
        }
      })
    },
    // 汇付支付成功
    paySuccess() {
      Toast('支付成功！')
      setTimeout(() => {
        this.Jump('/order-lists',{type:6})
      }, 1000)
    },
    // 汇付支付失败
    payError() {
      Toast('支付失败！')
      setTimeout(() => {
        this.Jump('/order-lists',{type:2})
      }, 1000)
    },
    anh_dz() {
      this.formData.item_id_json = JSON.stringify(this.formData.item_id)
      this.formData.sku_id_json = JSON.stringify(this.formData.sku_id)
      this.formData.sku_name_json = JSON.stringify(this.formData.sku_name)
      this.formData.current_price_json = JSON.stringify(this.formData.current_price)
      this.formData.current_dollar_price_json = JSON.stringify(this.formData.current_dollar_price)
      this.formData.sup_post_fee_json = JSON.stringify(this.formData.sup_post_fee)
      this.formData.new_supplier_id_json = JSON.stringify(this.formData.new_supplier_id)
      this.formData.is_first_gift_json = JSON.stringify(this.formData.is_first_gift)
      this.formData.buy_gift_type_json = JSON.stringify(this.formData.buy_gift_type)
      this.formData.supplier_id_json = JSON.stringify(this.formData.supplier_id)
      this.formData.active_json = JSON.stringify(this.formData.active)
      this.formData.num_json = JSON.stringify(this.formData.num)
      this.formData.order_extry_date_json = JSON.stringify(this.formData.order_extry_date)
      this.formData.order_extry_memo_json = JSON.stringify(this.formData.order_extry_memo)
      delete this.formData.item_id
      delete this.formData.sku_id
      delete this.formData.sku_name
      delete this.formData.current_price
      delete this.formData.current_dollar_price
      delete this.formData.sup_post_fee
      delete this.formData.new_supplier_id
      delete this.formData.is_first_gift
      delete this.formData.buy_gift_type
      delete this.formData.supplier_id
      delete this.formData.active
      delete this.formData.num
      delete this.formData.order_extry_date
      delete this.formData.order_extry_memo
    },
    // 拼团提交订单
    GroupShoppingOrder() {
      if (this.is_dataset_json == 1) {
        this.anh_dz()
      }
      if (this.paymentDataList.tlfz_deposit == 1 && this.money_type && this.paymentDataList.is_need_change_bind_phone) {
        this.$refs.tlInfo.handleShow({
          ishow: true
        })
        // console.log(this.paymentDataList)
        this.isSubmit = false
        return false
      }
      this.isSubmit = true
      if (this.formData.type == 26 && this.money_type) {
        this.formData.tlfz_pay_type = 4
      }
      GroupShoppingOrder(this.formData).then(res => {
        this.order_id = res.data.order_id
        this.isSubmit = false
        if (res.status == 1) {
          // console.log(res)
          // 微信支付
          if ((this.formData.type == 2 || this.formData.type == 19 || (this.formData.type == 26 && !res.data.is_mini_vsp) || this.formData.type == 29 || this.formData.type == 34 || this.formData.type == 48) && res.data.jsApiParameters) {
            if (this.formData.type == 34) {
              if (small.wxCache('adapayPlugVersion') == 'jump_adapay_mini') {
                const jsApiParameters = typeof res.data.jsApiParameters == 'object' ? res.data.jsApiParameters: JSON.parse(res.data.jsApiParameters)
                this.hfAppId = jsApiParameters.wx_app_id
                const that = this
                wx.navigateToMiniProgram({
                  appId: jsApiParameters.wx_app_id,
                  path: jsApiParameters.miniapp_path,
                  success(res) {
                    // 打开成功
                    // console.log(res)
                  },
                  fail(error) {
                    // that.$Error('跳转失败')
                    // this.isSubmit = false
                    that.Jump('buySuccess', {id: res.data.order_id})
                  }
                })
              } else if (small.wxCache('adapayPlugVersion') == 'self') {
                this.isSubmit = false
                smllpay.wxOrderPay(res.data.jsApiParameters)
              } else {
                const adapayPlugin = small.wxCache('adapayPlugVersion') == 'new' ? requirePlugin("Adapay") : requirePlugin("adapay-plugin")
                // 汇付分账
                const hfPay= res.data.jsApiParameters
                if (hfPay) {
                  adapayPlugin.requestPay(hfPay, this.paySuccess, this.payError);
                }
              }
            } else {
              smllpay.wxOrderPay(res.data.jsApiParameters)
            }
          } else if (this.formData.type == 26 && res.data.is_mini_vsp) {
            this.Jump('/buyTonglianWait',{ order_id: res.data.order_id, pay_type: 1 })
          }
          // TODO 跳转
          if (res.data && res.data.redirect_url) {
            if (this.paymentWay != 'peerpay ') {
              this.$Error('支付成功')
            }
            setTimeout(() => {
              openPage(res.data.redirect_url)
            }, 1000)
          }
          // 通联余额支付
          if (this.formData.type == 26 && this.money_type) {
            this.$refs.sendCodePayment.handleShow({
              order_id: res.data.order_id,
              tlfz_pay_type: this.formData.tlfz_pay_type
            })
          }
          // alert(res.data.redirect_url)
          // window.location.href = res.data.redirect_url
          // 通联余额支付
          if (this.formData.type == 26 && this.money_type) {
            this.$refs.sendCodePayment.handleShow({
              order_id: res.data.order_id,
              tlfz_pay_type: this.formData.tlfz_pay_type
            })
          }
        } else {
          this.$Error(res.msg)
        }
      })
    },
    // 处方药定制 跳转h5问诊
    jumpConsulationUrl(order_id) {
      // console.log('dzJumpMedicinedzJumpMedicine')
      const data = {
        order_id: order_id
      }
      medicineUrl(data).then(res => {
        if (res.status == 1) {
          // window.location.href = res.data
          let url = res.data
          // console.log('urlurl:', url)
          Store.saveLocal('webSrc', url)
          this.$JumpName(this, 'webView', {title: '处方药'})
        } else {
          this.$Error(res.msg)
        }
      })
    },
    // 选中国际支付宝抛出的值
    globalAlipay(val) {
      this.formData.global_alipay_currency = val
    },
    // 身份证正面
    /**
     * 上传图片
     */
    afterReadPros(file) {
      const form = new FormData()
      form.append('file', file.file)
      this.$loadingWrap.show()
      setTimeout(() => {
        this.$loadingWrap.close()
      }, 50000)
      uploadImgs(form).then(res => {
        this.$loadingWrap.close()
        if (res.status === 1) {
          this.formData.id_pros = res.data.pic_url
        } else {
          this.$Error('上传失败, 请重新上传')
        }
      })
    },

    // 身份证反面
    /**
     * 上传图片
     */
    afterReadCons(file) {
      const form = new FormData()
      form.append('file', file.file)
      this.$loadingWrap.show()
      setTimeout(() => {
        this.$loadingWrap.close()
      }, 50000)
      uploadImgs(form).then(res => {
        this.$loadingWrap.close()
        if (res.status === 1) {
          this.formData.id_cons = res.data.pic_url
        } else {
          this.$Error('上传失败, 请重新上传')
        }
      })
    },
    // 上传图片
    uploadImgListIssue(val) {
      const arr = []
      val.forEach(item => {
        arr.push(item.content)
      })
      this.formData.custom_pic = arr
    },

    // 获取运费
    getPostFee(getPostFeeflag) {
      if (getPostFeeflag) {
        const buy_type = this.resData.type
        const data = {
          sup_freight_tpl_id: [],
          sup_item_total_num: [],
          sup_post_weights: [],
          sup_post_volumes: [],
          freight_tpl_id: this.resData.freight_tpl_id,
          group_shopping_id: this.resData.group_shopping_id,
          freight_tpl_payment: this.resData.freight_tpl_payment,
          item_total_num: this.resData.item_total_num,
          province_id: this.formData.province_id,
          area_id: this.formData.area_id,
          city_id: this.formData.city_id,
          item_total_weight: this.resData.item_total_weight,
          volume: this.resData.item_total_volume,
          shipping_type: this.formData.shipping_type,
          item_ids: this.itemIds,
          nums: this.num,
          supplier_ids: this.supplier_ids,
          buy_type: buy_type,
          max_coupon_value: this.formData.max_coupon_value,
          allow_coupon_items: this.formData.allow_coupon_items,
          json_real_price: this.formData.json_real_price,
          user_coupon_id: this.formData.user_coupon_id,
          beforePayment: this.totalPrice,
          payment: this.resData.payment,
          amount_after_discount: this.reCountPrice - this.postFee
        }
        if (this.resData.supplier_ids && buy_type == 'oncart') {
          this.buyLists.forEach((item, indx) => {
            data.sup_freight_tpl_id.push(item.sup_freight_tpl_id)
            data.sup_item_total_num.push(item.sup_item_total_num)
            data.sup_post_weights.push(item.sup_post_weights)
            data.sup_post_volumes.push(item.sup_post_volumes)
          })
          // 供应商运费
          getSupplierPostFee(data).then(res => {
            if (res.status == 1) {
              this.postFee = parseFloat(res.data.post_fee).toFixed(2)
            } else {
              this.$Error(res.msg)
              if (res.errorCode == 'E00001') {
                this.isOrder = true
                setTimeout(() => {
                  wx.navigateBack({})
                  this.Jump('/shop-car')
                }, 2000)
              }
            }
          })
        } else {
          // 供应链 定制
          if (this.is_jh_item_dz) {
            data.is_jh_item_dz = 1
            data.jh_address_id = this.formData.address_id
            const skuDataDz = []
            if (this.resData.buy_lists.length > 0) {
              this.resData.buy_lists.forEach((item) => {
                const skuobj = {
                  sku_id: item.sku_id || '',
                  num: item.num
                }
                skuDataDz.push(skuobj)
              })
            }
            data.jh_item_info = JSON.stringify(skuDataDz)
          }
          // 星链供应链定制
          if (this.is_star_chain_item_dz) {
            data.is_star_chain_item_dz = 1
            data.star_address_id = this.formData.address_id
            const skuDataDz = []
            if (this.resData.buy_lists.length > 0) {
              this.resData.buy_lists.forEach((item) => {
                const skuobj = {
                  item_id: item.item_id,
                  sku_id: item.sku_id || '',
                  num: item.num
                }
                skuDataDz.push(skuobj)
              })
            }
            data.star_item_info = JSON.stringify(skuDataDz)
          }
        // 普通运费
          getPostFee(data).then(res => {
            if (res.status == 1) {
              this.postFee = parseFloat(res.data.post_fee).toFixed(2)
              this.isOrder = false
            } else {
              this.$Error(res.msg)
              if (res.msg == '该区域不支持配送') {
                this.isOrder = true
              } else {
                this.isOrder = false
              }
            }
          })
        }
      }
    },
    // 显示运费险
    showFreightInsurance() {
      this.isShowFreightInsurance = true
    },
    hideFreightInsurance() {
      this.isShowFreightInsurance = false
      this.formData.is_freight_insurance = 0
    },
    // 显示隐藏购买协议
    showPurchaseAgreement(itemId) {
      if (this.resData.is_item_agreement == 1) {
        const oAgreementList = this.resData.item_agreement_lists.filter(item => item.item_id == itemId)[0]
        this.isShowPurchaseAgreement = true
        this.purchase_agreement_content = oAgreementList.purchase_agreement_content || oAgreementList.item_agreement_content
        this.purchase_agreement_name = oAgreementList.purchase_agreement_name
      } else {
        this.isShowPurchaseAgreement = true
      }
    },
    closePurchaseAgreement() {
      this.isShowPurchaseAgreement = false
    },
    // 显示定制优惠码弹层
    dzDiscountCode() {
      // 欧普定制
      if (this.couponPrice != 0 || this.couponCodePrice != 0) {
        this.$Error('已使用其它优惠')
        return false
      }
      this.$refs.dzDiscountCode.showCouponPop = true
    },
    // 显示优惠码弹层
    discountCode() {
      // 欧普定制
      if (this.dzCouponCodePrice != 0) {
        this.$Error('已使用其它优惠')
        return false
      }
      this.$refs.discountCode.showCouponPop = true
    },
    // 定制供应商优惠券金额
    dzDiscountCouponValue(userCouponId) {
      if (!userCouponId || userCouponId == -1) {
        this.couponSupPrice = 0
        return this.resData.coupon_num_ZJHL_DZ + '张可用'
      } else {
        let str = ''
        this.coupon_lists_ZJHL_DZ.forEach((item, index) => {
          if (item.user_coupon_id == userCouponId) {
            this.couponSupPrice = parseFloat(item.value)
            str = '-¥' + item.value
          }
        })
        return str
      }
    },
    // 优惠券金额
    discountCouponValue(userCouponId) {
      if (!userCouponId || userCouponId == -1) {
        this.couponPrice = 0
        return this.resData.coupon_num + '张可用'
      } else {
        let str = ''
        this.coupon_lists.forEach((item, index) => {
          if (item.user_coupon_id == userCouponId) {
            this.couponPrice = parseFloat(item.value)
            str = '-¥' + item.value
          }
        })
        return str
      }
    },
    // 显示供应商优惠券弹层
    dzDiscountCoupon() {
      this.$refs.dzDiscountCoupon.showCouponPop = true
    },
    // 显示优惠券弹层
    discountCoupon() {
      // 欧普定制
      if (this.dzCouponCodePrice != 0) {
        this.$Error('已使用其它优惠')
        return false
      }
      this.$refs.discountCoupon.showCouponPop = true
    },

    // 显示多买优惠弹层
    showBmdPop() {
      this.$refs.bmdPop.showBmdPop = true
    },
    // 显示发票窗口
    showBill() {
      this.$refs.bill.showBillPop = true
    },
    // 获取预约日期和时间
    dateTime(date, time) {
      this.formData.reservation_service_date = date
      this.formData.reservation_service_time = time
      this.subscribeTime = date + ' ' + time
    },
    // 显示选择预约时间弹窗
    selectSubDate() {
      this.$refs.subscribe.clickStart()
    },
    // 获取配送方式
    getShippingType(data) {
      this.formData.shipping_type = data
      if (data ==4 || data ==5) {
        this.onGetLocation()
      } else {
        this.isDingWei = true
      }
      // console.log('getShippingType', data, this.isDingwei)
    },
    // 获取自提地址
    getSelfAddress(val) {
      // console.log('getSelfAddress', val)
      if (val) {
          if (this.formData.shipping_type == 5 && val.distribute_distance > 0) {
            if (val.distribute_distance < val.distance) {
              this.$Error('超出配送范围，请重新选择地址')
              return false
            }
          }
        }
        this.selfAddressInfo = val
      // if ((this.formData.shipping_type == 5 || this.formData.shipping_type == 4)) {
      //   this.onGetLocation('getSelfAddress', val)
      // } else {
      //   if (val) {
      //     if (this.formData.shipping_type == 5 && val.distribute_distance > 0) {
      //       if (val.distribute_distance < val.distance) {
      //         this.$Error('超出配送范围，请重新选择地址')
      //         return false
      //       }
      //     }
      //   }
      //   this.selfAddressInfo = val
      // }
    },
    // 获取日期时间
    getDateTime(val) {
      this.$refs.subscribe.columns = val
      // // console.log(val)
    },
    // 获取自提地址
    getStoreSelfAddress(val) {
      this.selfStoreAddressInfo = val
      this.formData.serve_address_id = this.selfStoreAddressInfo.self_address_id
      const $refDlgCpt = this.$refs['store-serve-addr-dlg-cpt']
      if ($refDlgCpt) {
        $refDlgCpt.handleCloseDialog()
      }
    },
    scaleGoodsPriceFn(price) {
      return scaleGoodsPrice(price)
    },
    selectStoreServe() {
      this.storeSveAddrDlg.visible = true
    },
    // 点击选择自提地址
    openSelfAddress(addressData) {
      // 门店配送选择门店配送地址时获取收货地址的经纬度
      if (this.formData.shipping_type == 5 && addressData.latitude && addressData.latitude != 0) {
        // console.log('addressData', addressData.latitude)
        this.formData.latitude = addressData.latitude
        this.formData.longitude = addressData.longitude
      } else {
        this.formData.latitude = undefined
        this.formData.longitude = undefined
      }
      // 调用子组件方法
      if (this.$refs.modeDistribution) {
        this.$refs.modeDistribution.selfAddressVisible = false
        this.$refs.modeDistribution.$refs.selfAddressDialog.dialogVisible = false
        this.$refs.modeDistribution.$refs.selfAddressDialog.dialogVisible = true
      }
    },
    paymentData(data) {
      // console.log(data, '测试demo lesson')
      this.paymentDataList = data
    },
    Jump(url, data) {
      this.$JumpPath(this, url, data)
    },
    JumpName(url, data) {
      this.$JumpName(this, url, data)
    },

    JumpUrl(url, data) {
      window.location.href = url
    },

    // 获取限购提示数据
    handleLimitBuyPage() {
      getLimitBuyPage().then(res => {
        if (res.status == 1) {
          this.purchasingPrompt.content = res.data.PModules[0].content
          this.purchasingPrompt.goto_time = res.data.page.goto_time
          const oTime = this.purchasingPrompt.goto_time * 1000
          setTimeout(() => {
            wx.navigateBack({
              delta: 1
            })
            this.isShowurPchasingTip = false
          }, oTime)
        }
      })
    },
    // 定制 医疗定制 start
    showPrescriptionInfo() {
      this.heightCfy = '100%'
      this.position = 'right'
      this.type = ''
      this.show_prescriptionInfo = true
    },
    closeClick() {
      this.show_prescriptionInfo = false
    },
    prescriptionInfoSaveClick(data) {
      this.medical_patient_id = data
      if (this.type == 'buy') {
        this.openPayPop()
      }
    }
    // 定制 医疗定制 end
  },
  created() {
    this.memberItemId = this.$route.query.itemId
     if (this.memberItemId) {
       this.ischjDz = true
     }
    let shop = small.globalData.shopId
    const ltsn_dz = this.$_shop('$_ltsn_dz', shop)
    this.ltnsStatus = ltsn_dz
    if (small.wxCache('adapayPlugVersion') == 'jump_adapay_mini') {
      this.remark = 1
    }
    // console.log('ltnsStatus', this.ltnsStatus )
  },
  mounted() {
    if (small.wxCache('adapayPlugVersion') == 'jump_adapay_mini') {
      window.addEventListener('wxshow', () => {
        let options = wx.getEnterOptionsSync();
        // wx1e18d140f890f2c5，wx308088053f4ecc3a
        if (options.scene == '1038' && options.referrerInfo.appId == this.hfAppId && this.remark == 2) {
          // 代表从收银台小程序返回
          this.Jump('buySuccess', {id: this.order_id})
          // this.isSubmit = false
        }
      }),
      window.addEventListener('wxHide', () => {
        this.remark = 2
      })
    }
    window.addEventListener('wxload', () => {
      this.init()

    //   wx.getLocation({
    //     type: 'gcj02',
    //     success: (res) => {
    //       // console.log(res, '定位成功')
    //       this.formData.latitude = res.latitude
    //       this.formData.longitude = res.longitude
    //       this.init()
    //       // 门店服务地址列表
    //       const $refDlgCpt = this.$refs['store-serve-addr-dlg-cpt']
    //       if ($refDlgCpt) {
    //         $refDlgCpt.selfAddressCountFn('auto', this.formData.latitude, this.formData.longitude)
    //       }
    //     },
    //     fail: (resp) => {
    //       // 代表手机没有开启手机定位权限
    //       if (resp.errMsg == 'getLocation:fail system permission denied' || resp.errMsg == 'getLocation:fail:ERROR_NOCELL&WIFI_LOCATIONSWITCHOFF') {
    //         this.$Error('请开启手机定位，以便体验更好的服务')
    //         this.init()
    //       } else {
    //         wx.getSetting({
    //           success (res) {
    //             if (!res.authSetting['scope.userLocation']) {
    //               wx.showModal({
    //                 title:'温馨提示',
    //                 content:'小程序将获取您的授权用来显示位置信息',
    //                 showCancel: false,
    //                 success(res){
    //                   if(res.confirm){
    //                     // console.log('点击了确认');
    //                     wx.openSetting({
    //                       success (res) {
    //                         // console.log(res.authSetting)
    //                         res.authSetting = {
    //                           "scope.userInfo": true,
    //                           "scope.userLocation": true
    //                         }
    //                       }
    //                     })
    //                   }
    //                 }
    //               })
    //             }
    //           }
    //         })
    //       }
    //       // console.log(resp, '定位失败')
    //     }
    //   })
    })
    // TODO 接受支付密码页面广播 刷新页面
      window.$$subscribe('payPasswordRefresh', data => {
        // console.log('payPasswordRefresh', data)
        this.showPwd = false
        this.init()
      })

  },
  beforeDestroy() {
    // TODO 取消订阅
      window.$$unsubscribe('payPasswordRefresh')
  }
})
</script>

<style lang="scss">
  .prescription-info-wrapper {
    padding: 30px 20px;
    background: #FEF2E4;
    margin: 0 30px 24px;
    border-radius: 20px;
    .prescription-info {
      display: flex;
      justify-content: space-between;
      align-items: center;
      .left {
        padding-left: 20px;
        border-left-style: solid;
        border-left-width: 10px;
        &.success {
          border-left-color: #03C28A;
        }
        &.warning {
          border-left-color: #FF702C;
        }
        .title {
          font-size: 32px;
          font-weight: bold;
        }
        .desc {
          font-size: 24px;
          margin-top: 16px;
          color: #999;
        }
      }
      .right {
        font-size: 24px;
        color: #999;
        flex-shrink: 0;
      }
    }
    .warning {
      color: #FF702C
    }
    .success {
      color: #03C28A
    }
  }
</style>
<style lang="scss">
@import "../../../styles/mixin";
@import "src/styles/order/orderBuy";
.miniprogram-root {
  .van-dialog {
    font-size: 32px;
  }
}
.small-pay {
  // .van-checkbox__label {
  //   margin-left: 46px;
  // }
  .icon-right{
    border: solid #666;
    border-width: 0 3px 3px 0;
    display: inline-block;
    padding: 4px;
    transform: rotate(-45deg);
    -webkit-transform: rotate(-45deg);
  }
}
// 限购提示
.pchasingTipConfirm{
  .van-dialog__footer{
    padding: 0 60px 48px;
    .van-dialog__confirm{
      height: 80px;
    }
  }
}
/*  常俊海 定制 会员服务购买*/
.memberpay-header {
  width: 714px;
  height: 400px;
  margin: auto;
  text-align: center;
  overflow: hidden;
  background-image: url("https://wifenxiao.oss-cn-hangzhou.aliyuncs.com/h5-wfx/images/DZ/changjunhai/memberPayBg.png");
  background-size: 100% 100%;

  .memberGrade-title {
    font-size: 28px;
    font-weight: 400;
    color: #333333;
    margin-top: 116px;
  }

  .memberGrade-price {
    font-size: 64px;
    font-weight: 500;
    color: #333333;
    margin-top: 28px;

    span:nth-child(1) {
      font-size: 32px !important;
    }
  }
}
.cashPoint{
  border-bottom: none !important;
}
.exchangeFee{
  color: #B6B6B6;
  line-height: 50px;
  border-bottom: 1px solid #EDEDED;
}
.item-block.item-block2 {
  .item-box {
  .custom-pic-title.item-title {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    height: auto;
    .flex-shrink {
      flex-shrink: 0;
    }
    .cunstom-text {
      line-height: 1.2;
      height: auto;
      margin-left: 20px;
      padding: 18px 0;
    }
  }
  }
}
.btn-disable{
  background: #cecece !important;
}
// 定制 赠品
.gift-list {
  padding: 20px;
  .title {
    font-size: 28px;
    font-weight: 500
  }
  .gift-sku {
    .small-title {
      margin: 20px 0 10px 0;
    }
    .gift-dz {
      display:flex;
      flex-wrap: wrap;
      div{
        background: #F2F2F2;
        border: 1px solid #F2F2F2;
        margin-bottom: 20px;
        color: #333;
        font-size:24px;
        padding: 2px 30px;
        border-radius: 50px;
        margin-right: 24px;
        &.click-gift-sku {
          background: #F21228;
          border:1p solid #F21228;
          color:#fff
        }

      }
    }
  }
}
.wxPop {
  width: 80%;
  .van-dialog-header {
    font-size: 28px;
  }
  .van-dialog__content {
    margin: 40px 0;
    .van-dialog__message--has-title {
      font-size: 28px;
    }
  }
  .van-dialog__footer {
    margin: 0;
    padding: 0;
    border-top: 2px solid #efefef;
    background: #fff;
    .van-button__text {
      color: #61698e;
      font-size: 28px;
      font-weight: 500
    }
    .van-dialog__confirm {
      padding: 40px
    }
  }
}
.text-tips {
  font-size: 24px;
  // margin-bottom: 30px;
  padding: 20px 0;
  color: #F30C23;
  text-align: center;
  background: transparent;
}
</style>
